From b54cafe5cee93a35bf6b061e261e8265ea0a628c Mon Sep 17 00:00:00 2001 From: Loren Osborn Date: Thu, 18 Oct 2018 09:33:43 -0700 Subject: [PATCH] Addresses @stevvooe's backward compatibility concerns. --- logrus.go | 12 +++++++++--- logrus_test.go | 7 +++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/logrus.go b/logrus.go index 8834b5b..03046b6 100644 --- a/logrus.go +++ b/logrus.go @@ -121,7 +121,6 @@ type FieldLogger interface { WithFields(fields Fields) *Entry WithError(err error) *Entry - Tracef(format string, args ...interface{}) Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Printf(format string, args ...interface{}) @@ -131,7 +130,6 @@ type FieldLogger interface { Fatalf(format string, args ...interface{}) Panicf(format string, args ...interface{}) - Trace(args ...interface{}) Debug(args ...interface{}) Info(args ...interface{}) Print(args ...interface{}) @@ -141,7 +139,6 @@ type FieldLogger interface { Fatal(args ...interface{}) Panic(args ...interface{}) - Traceln(args ...interface{}) Debugln(args ...interface{}) Infoln(args ...interface{}) Println(args ...interface{}) @@ -158,3 +155,12 @@ type FieldLogger interface { // IsFatalEnabled() 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{}) +} diff --git a/logrus_test.go b/logrus_test.go index 210feef..748f0ba 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -453,9 +453,12 @@ func TestReplaceHooks(t *testing.T) { } // Compile test -func TestLogrusInterface(t *testing.T) { +func TestLogrusInterfaces(t *testing.T) { 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.Debug("Test") }