diff --git a/intlogger.go b/intlogger.go index e4cd8ed..89d26c9 100644 --- a/intlogger.go +++ b/intlogger.go @@ -261,7 +261,6 @@ func needsQuoting(str string) bool { // 2. Color the whole log line, based on the level. // 3. Color only the header (level) part of the log line. // 4. Color both the header and fields of the log line. -// func (l *intLogger) logPlain(t time.Time, name string, level Level, msg string, args ...interface{}) { if !l.disableTime { @@ -845,6 +844,11 @@ func (l *intLogger) SetLevel(level Level) { atomic.StoreInt32(l.level, int32(level)) } +// Returns the current level +func (l *intLogger) GetLevel() Level { + return Level(atomic.LoadInt32(l.level)) +} + // Create a *log.Logger that will send it's data through this Logger. This // allows packages that expect to be using the standard library log to actually // use this logger. diff --git a/logger.go b/logger.go index 50dee82..3cdb283 100644 --- a/logger.go +++ b/logger.go @@ -198,6 +198,9 @@ type Logger interface { // implementation cannot update the level on the fly, it should no-op. SetLevel(level Level) + // Returns the current level + GetLevel() Level + // Return a value that conforms to the stdlib log.Logger interface StandardLogger(opts *StandardLoggerOptions) *log.Logger diff --git a/nulllogger.go b/nulllogger.go index bc14f77..55e89dd 100644 --- a/nulllogger.go +++ b/nulllogger.go @@ -49,6 +49,8 @@ func (l *nullLogger) ResetNamed(name string) Logger { return l } func (l *nullLogger) SetLevel(level Level) {} +func (l *nullLogger) GetLevel() Level { return NoLevel } + func (l *nullLogger) StandardLogger(opts *StandardLoggerOptions) *log.Logger { return log.New(l.StandardWriter(opts), "", log.LstdFlags) }