From aa3ad346e42c2150c4d71f3b15dcf3d6041d9bef Mon Sep 17 00:00:00 2001 From: Simon Eskildsen Date: Thu, 23 Jul 2015 21:45:57 -0400 Subject: [PATCH] Revert "Merge pull request #208 from Arkan/master" This reverts commit 7eac5879a50743ef4bd83fae92cf9a97c2d70f45, reversing changes made to c79ccaf8c2b6e7361c430b45aae6891fca8ff729. --- CHANGELOG.md | 4 ++++ entry.go | 41 ++++++++++++++++++++--------------------- entry_test.go | 14 -------------- 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5fe2f..e696bc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.8.5 + +logrus/core: revert #208 + # 0.8.4 formatter/text: fix data race (#218) diff --git a/entry.go b/entry.go index 2a98065..699ea03 100644 --- a/entry.go +++ b/entry.go @@ -32,8 +32,7 @@ func NewEntry(logger *Logger) *Entry { return &Entry{ Logger: logger, // Default is three fields, give a little extra room - Data: make(Fields, 5), - Level: logger.Level, + Data: make(Fields, 5), } } @@ -68,7 +67,7 @@ func (entry *Entry) WithFields(fields Fields) *Entry { for k, v := range fields { data[k] = v } - return &Entry{Logger: entry.Logger, Data: data, Level: entry.Level} + return &Entry{Logger: entry.Logger, Data: data} } func (entry *Entry) log(level Level, msg string) { @@ -106,7 +105,7 @@ func (entry *Entry) log(level Level, msg string) { } func (entry *Entry) Debug(args ...interface{}) { - if entry.Level >= DebugLevel { + if entry.Logger.Level >= DebugLevel { entry.log(DebugLevel, fmt.Sprint(args...)) } } @@ -116,13 +115,13 @@ func (entry *Entry) Print(args ...interface{}) { } func (entry *Entry) Info(args ...interface{}) { - if entry.Level >= InfoLevel { + if entry.Logger.Level >= InfoLevel { entry.log(InfoLevel, fmt.Sprint(args...)) } } func (entry *Entry) Warn(args ...interface{}) { - if entry.Level >= WarnLevel { + if entry.Logger.Level >= WarnLevel { entry.log(WarnLevel, fmt.Sprint(args...)) } } @@ -132,20 +131,20 @@ func (entry *Entry) Warning(args ...interface{}) { } func (entry *Entry) Error(args ...interface{}) { - if entry.Level >= ErrorLevel { + if entry.Logger.Level >= ErrorLevel { entry.log(ErrorLevel, fmt.Sprint(args...)) } } func (entry *Entry) Fatal(args ...interface{}) { - if entry.Level >= FatalLevel { + if entry.Logger.Level >= FatalLevel { entry.log(FatalLevel, fmt.Sprint(args...)) } os.Exit(1) } func (entry *Entry) Panic(args ...interface{}) { - if entry.Level >= PanicLevel { + if entry.Logger.Level >= PanicLevel { entry.log(PanicLevel, fmt.Sprint(args...)) } panic(fmt.Sprint(args...)) @@ -154,13 +153,13 @@ func (entry *Entry) Panic(args ...interface{}) { // Entry Printf family functions func (entry *Entry) Debugf(format string, args ...interface{}) { - if entry.Level >= DebugLevel { + if entry.Logger.Level >= DebugLevel { entry.Debug(fmt.Sprintf(format, args...)) } } func (entry *Entry) Infof(format string, args ...interface{}) { - if entry.Level >= InfoLevel { + if entry.Logger.Level >= InfoLevel { entry.Info(fmt.Sprintf(format, args...)) } } @@ -170,7 +169,7 @@ func (entry *Entry) Printf(format string, args ...interface{}) { } func (entry *Entry) Warnf(format string, args ...interface{}) { - if entry.Level >= WarnLevel { + if entry.Logger.Level >= WarnLevel { entry.Warn(fmt.Sprintf(format, args...)) } } @@ -180,20 +179,20 @@ func (entry *Entry) Warningf(format string, args ...interface{}) { } func (entry *Entry) Errorf(format string, args ...interface{}) { - if entry.Level >= ErrorLevel { + if entry.Logger.Level >= ErrorLevel { entry.Error(fmt.Sprintf(format, args...)) } } func (entry *Entry) Fatalf(format string, args ...interface{}) { - if entry.Level >= FatalLevel { + if entry.Logger.Level >= FatalLevel { entry.Fatal(fmt.Sprintf(format, args...)) } os.Exit(1) } func (entry *Entry) Panicf(format string, args ...interface{}) { - if entry.Level >= PanicLevel { + if entry.Logger.Level >= PanicLevel { entry.Panic(fmt.Sprintf(format, args...)) } } @@ -201,13 +200,13 @@ func (entry *Entry) Panicf(format string, args ...interface{}) { // Entry Println family functions func (entry *Entry) Debugln(args ...interface{}) { - if entry.Level >= DebugLevel { + if entry.Logger.Level >= DebugLevel { entry.Debug(entry.sprintlnn(args...)) } } func (entry *Entry) Infoln(args ...interface{}) { - if entry.Level >= InfoLevel { + if entry.Logger.Level >= InfoLevel { entry.Info(entry.sprintlnn(args...)) } } @@ -217,7 +216,7 @@ func (entry *Entry) Println(args ...interface{}) { } func (entry *Entry) Warnln(args ...interface{}) { - if entry.Level >= WarnLevel { + if entry.Logger.Level >= WarnLevel { entry.Warn(entry.sprintlnn(args...)) } } @@ -227,20 +226,20 @@ func (entry *Entry) Warningln(args ...interface{}) { } func (entry *Entry) Errorln(args ...interface{}) { - if entry.Level >= ErrorLevel { + if entry.Logger.Level >= ErrorLevel { entry.Error(entry.sprintlnn(args...)) } } func (entry *Entry) Fatalln(args ...interface{}) { - if entry.Level >= FatalLevel { + if entry.Logger.Level >= FatalLevel { entry.Fatal(entry.sprintlnn(args...)) } os.Exit(1) } func (entry *Entry) Panicln(args ...interface{}) { - if entry.Level >= PanicLevel { + if entry.Logger.Level >= PanicLevel { entry.Panic(entry.sprintlnn(args...)) } } diff --git a/entry_test.go b/entry_test.go index f7de400..98717df 100644 --- a/entry_test.go +++ b/entry_test.go @@ -51,17 +51,3 @@ func TestEntryPanicf(t *testing.T) { entry := NewEntry(logger) entry.WithField("err", errBoom).Panicf("kaboom %v", true) } - -func TestEntryLogLevel(t *testing.T) { - out := &bytes.Buffer{} - logger := New() - logger.Out = out - logger.Level = DebugLevel - entry := NewEntry(logger) - assert.Equal(t, DebugLevel, entry.Level) - entry.Level = WarnLevel - entry.Info("it should not be displayed") - assert.Equal(t, "", out.String()) - entry.Warn("it should be displayed") - assert.Contains(t, out.String(), "it should be displayed") -}