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{})
|
Fatalln(args ...interface{})
|
||||||
Panicln(args ...interface{})
|
Panicln(args ...interface{})
|
||||||
|
|
||||||
SetLevel(level Level)
|
|
||||||
IsLevelEnabled(level Level) bool
|
|
||||||
// IsDebugEnabled() bool
|
// IsDebugEnabled() bool
|
||||||
// IsInfoEnabled() bool
|
// IsInfoEnabled() bool
|
||||||
// IsWarnEnabled() bool
|
// IsWarnEnabled() bool
|
||||||
|
@ -178,6 +176,12 @@ type FieldLogger interface {
|
||||||
// IsPanicEnabled() bool
|
// IsPanicEnabled() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Ext2FieldLogger interface {
|
||||||
|
FieldLogger
|
||||||
|
SetLevel(level Level)
|
||||||
|
IsLevelEnabled(level Level) bool
|
||||||
|
}
|
||||||
|
|
||||||
// Ext1FieldLogger (the first extension to FieldLogger) is superfluous, it is
|
// Ext1FieldLogger (the first extension to FieldLogger) is superfluous, it is
|
||||||
// here for consistancy. Do not use. Use Logger or Entry instead.
|
// here for consistancy. Do not use. Use Logger or Entry instead.
|
||||||
type Ext1FieldLogger interface {
|
type Ext1FieldLogger interface {
|
||||||
|
|
|
@ -631,14 +631,23 @@ func TestLogrusInterfaces(t *testing.T) {
|
||||||
b := l.WithField("key", "value")
|
b := l.WithField("key", "value")
|
||||||
b.Debug("Test")
|
b.Debug("Test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn2 := func(xl Ext2FieldLogger) {
|
||||||
|
var l FieldLogger = xl
|
||||||
|
b := l.WithField("key", "value")
|
||||||
|
b.Debug("Test")
|
||||||
|
}
|
||||||
|
|
||||||
// test logger
|
// test logger
|
||||||
logger := New()
|
logger := New()
|
||||||
logger.Out = &buffer
|
logger.Out = &buffer
|
||||||
fn(logger)
|
fn(logger)
|
||||||
|
fn2(logger)
|
||||||
|
|
||||||
// test Entry
|
// test Entry
|
||||||
e := logger.WithField("another", "value")
|
e := logger.WithField("another", "value")
|
||||||
fn(e)
|
fn(e)
|
||||||
|
fn2(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements io.Writer using channels for synchronization, so we can wait on
|
// Implements io.Writer using channels for synchronization, so we can wait on
|
||||||
|
|
Loading…
Reference in New Issue