From 1e2ce57d98f787b7b062608f0cacd9736a6a8dd8 Mon Sep 17 00:00:00 2001 From: Ilya Galimyanov Date: Wed, 18 Apr 2018 01:52:22 +0300 Subject: [PATCH] Make GlobalLevel a public function (#53) --- globals.go | 3 ++- log.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/globals.go b/globals.go index b65d0cb..5c2aa9c 100644 --- a/globals.go +++ b/globals.go @@ -49,7 +49,8 @@ func SetGlobalLevel(l Level) { atomic.StoreUint32(gLevel, uint32(l)) } -func globalLevel() Level { +// GlobalLevel returns the current global log level +func GlobalLevel() Level { return Level(atomic.LoadUint32(gLevel)) } diff --git a/log.go b/log.go index 6ca93bb..e446f2f 100644 --- a/log.go +++ b/log.go @@ -366,7 +366,7 @@ func (l *Logger) newEvent(level Level, done func(string)) *Event { // should returns true if the log event should be logged. func (l *Logger) should(lvl Level) bool { - if lvl < l.level || lvl < globalLevel() { + if lvl < l.level || lvl < GlobalLevel() { return false } if l.sampler != nil && !samplingDisabled() {