Make GlobalLevel a public function (#53)

This commit is contained in:
Ilya Galimyanov 2018-04-18 01:52:22 +03:00 committed by Olivier Poitrey
parent 70bea47cc0
commit 1e2ce57d98
2 changed files with 3 additions and 2 deletions

View File

@ -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))
}

2
log.go
View File

@ -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() {