Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger: fix wrong callback method #893

Merged
merged 1 commit into from Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions logger.go
Expand Up @@ -200,7 +200,7 @@ func (logger *Logger) Info(args ...interface{}) {

func (logger *Logger) Print(args ...interface{}) {
entry := logger.newEntry()
entry.Info(args...)
entry.Print(args...)
logger.releaseEntry(entry)
}

Expand Down Expand Up @@ -256,7 +256,7 @@ func (logger *Logger) Warnln(args ...interface{}) {
}

func (logger *Logger) Warningln(args ...interface{}) {
logger.Warn(args...)
logger.Warnln(args...)
}

func (logger *Logger) Errorln(args ...interface{}) {
Expand Down
23 changes: 23 additions & 0 deletions logger_test.go
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -40,3 +41,25 @@ func TestNoFieldValueError(t *testing.T) {
_, ok := data[FieldKeyLogrusError]
require.False(t, ok)
}

func TestWarninglnNotEqualToWarning(t *testing.T) {
buf := &bytes.Buffer{}
bufln := &bytes.Buffer{}

formatter := new(TextFormatter)
formatter.DisableTimestamp = true
formatter.DisableLevelTruncation = true

l := &Logger{
Out: buf,
Formatter: formatter,
Hooks: make(LevelHooks),
Level: DebugLevel,
}
l.Warning("hello,", "world")

l.SetOutput(bufln)
l.Warningln("hello,", "world")

assert.NotEqual(t, buf.String(), bufln.String(), "Warning() and Wantingln() should not be equal")
}