mirror of https://github.com/sirupsen/logrus.git
Adding a new interface instead of updating FieldLogger
This commit is contained in:
parent
6abeffb8b1
commit
2d76c42baf
|
@ -168,8 +168,6 @@ type FieldLogger interface {
|
|||
Fatalln(args ...interface{})
|
||||
Panicln(args ...interface{})
|
||||
|
||||
SetLevel(level Level)
|
||||
IsLevelEnabled(level Level) bool
|
||||
// IsDebugEnabled() bool
|
||||
// IsInfoEnabled() bool
|
||||
// IsWarnEnabled() bool
|
||||
|
@ -178,6 +176,12 @@ type FieldLogger interface {
|
|||
// IsPanicEnabled() bool
|
||||
}
|
||||
|
||||
type Ext2FieldLogger interface {
|
||||
FieldLogger
|
||||
SetLevel(level Level)
|
||||
IsLevelEnabled(level Level) bool
|
||||
}
|
||||
|
||||
// Ext1FieldLogger (the first extension to FieldLogger) is superfluous, it is
|
||||
// here for consistancy. Do not use. Use Logger or Entry instead.
|
||||
type Ext1FieldLogger interface {
|
||||
|
|
|
@ -631,14 +631,23 @@ func TestLogrusInterfaces(t *testing.T) {
|
|||
b := l.WithField("key", "value")
|
||||
b.Debug("Test")
|
||||
}
|
||||
|
||||
fn2 := func(xl Ext2FieldLogger) {
|
||||
var l FieldLogger = xl
|
||||
b := l.WithField("key", "value")
|
||||
b.Debug("Test")
|
||||
}
|
||||
|
||||
// test logger
|
||||
logger := New()
|
||||
logger.Out = &buffer
|
||||
fn(logger)
|
||||
fn2(logger)
|
||||
|
||||
// test Entry
|
||||
e := logger.WithField("another", "value")
|
||||
fn(e)
|
||||
fn2(e)
|
||||
}
|
||||
|
||||
// Implements io.Writer using channels for synchronization, so we can wait on
|
||||
|
|
Loading…
Reference in New Issue