1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00

fix WithField error

This commit is contained in:
2022-05-11 17:24:44 +08:00
parent aac79b4997
commit ffaf129ddb
2 changed files with 8 additions and 3 deletions

View File

@ -27,11 +27,13 @@ func (l *logrusWrpper) SetLevel(level Level) {
}
func (l *logrusWrpper) WithField(key string, value any) Logger {
return l.WithFields(Fields{key: value})
return l.WithFields(Fields{key: value}).(*logrusWrpper)
}
func (l *logrusWrpper) WithFields(fields Fields) Logger {
return &logrusWrpper{
Entry: l.Logger.WithFields(logrus.Fields(fields)),
l = &logrusWrpper{
Entry: l.Entry.WithFields(logrus.Fields(fields)),
}
return l
}

View File

@ -26,6 +26,9 @@ func TestLogrus(t *testing.T) {
l.WithField("abc", "bcd").Info("aaaa")
l.WithField("bbb", "bbb").Info("bbbb")
l.WithField("ccc", "ccc").Info("cccc")
l = l.WithField("o", "o")
l.WithField("z", "z").Info("abcd")
}
func TestLevel(t *testing.T) {