Addresses @stevvooe's backward compatibility concerns.

This commit is contained in:
Loren Osborn 2018-10-18 09:33:43 -07:00
parent ef9d84e9b3
commit b54cafe5ce
2 changed files with 14 additions and 5 deletions

View File

@ -121,7 +121,6 @@ type FieldLogger interface {
WithFields(fields Fields) *Entry WithFields(fields Fields) *Entry
WithError(err error) *Entry WithError(err error) *Entry
Tracef(format string, args ...interface{})
Debugf(format string, args ...interface{}) Debugf(format string, args ...interface{})
Infof(format string, args ...interface{}) Infof(format string, args ...interface{})
Printf(format string, args ...interface{}) Printf(format string, args ...interface{})
@ -131,7 +130,6 @@ type FieldLogger interface {
Fatalf(format string, args ...interface{}) Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{}) Panicf(format string, args ...interface{})
Trace(args ...interface{})
Debug(args ...interface{}) Debug(args ...interface{})
Info(args ...interface{}) Info(args ...interface{})
Print(args ...interface{}) Print(args ...interface{})
@ -141,7 +139,6 @@ type FieldLogger interface {
Fatal(args ...interface{}) Fatal(args ...interface{})
Panic(args ...interface{}) Panic(args ...interface{})
Traceln(args ...interface{})
Debugln(args ...interface{}) Debugln(args ...interface{})
Infoln(args ...interface{}) Infoln(args ...interface{})
Println(args ...interface{}) Println(args ...interface{})
@ -158,3 +155,12 @@ type FieldLogger interface {
// IsFatalEnabled() bool // IsFatalEnabled() bool
// IsPanicEnabled() bool // IsPanicEnabled() 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 {
FieldLogger
Tracef(format string, args ...interface{})
Trace(args ...interface{})
Traceln(args ...interface{})
}

View File

@ -453,9 +453,12 @@ func TestReplaceHooks(t *testing.T) {
} }
// Compile test // Compile test
func TestLogrusInterface(t *testing.T) { func TestLogrusInterfaces(t *testing.T) {
var buffer bytes.Buffer var buffer bytes.Buffer
fn := func(l FieldLogger) { // This verifies FieldLogger and Ext1FieldLogger work as designed.
// Please don't use them. Use Logger and Entry directly.
fn := func(xl Ext1FieldLogger) {
var l FieldLogger = xl
b := l.WithField("key", "value") b := l.WithField("key", "value")
b.Debug("Test") b.Debug("Test")
} }