mirror of https://github.com/sirupsen/logrus.git
Merge pull request #893 from jiangxin/jx/fix-warningln
logger: fix wrong callback method
This commit is contained in:
commit
7d8d63893b
|
@ -200,7 +200,7 @@ func (logger *Logger) Info(args ...interface{}) {
|
||||||
|
|
||||||
func (logger *Logger) Print(args ...interface{}) {
|
func (logger *Logger) Print(args ...interface{}) {
|
||||||
entry := logger.newEntry()
|
entry := logger.newEntry()
|
||||||
entry.Info(args...)
|
entry.Print(args...)
|
||||||
logger.releaseEntry(entry)
|
logger.releaseEntry(entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ func (logger *Logger) Warnln(args ...interface{}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Warningln(args ...interface{}) {
|
func (logger *Logger) Warningln(args ...interface{}) {
|
||||||
logger.Warn(args...)
|
logger.Warnln(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (logger *Logger) Errorln(args ...interface{}) {
|
func (logger *Logger) Errorln(args ...interface{}) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,3 +41,25 @@ func TestNoFieldValueError(t *testing.T) {
|
||||||
_, ok := data[FieldKeyLogrusError]
|
_, ok := data[FieldKeyLogrusError]
|
||||||
require.False(t, ok)
|
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")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue