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:
@ -27,11 +27,13 @@ func (l *logrusWrpper) SetLevel(level Level) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *logrusWrpper) WithField(key string, value any) Logger {
|
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 {
|
func (l *logrusWrpper) WithFields(fields Fields) Logger {
|
||||||
return &logrusWrpper{
|
l = &logrusWrpper{
|
||||||
Entry: l.Logger.WithFields(logrus.Fields(fields)),
|
Entry: l.Entry.WithFields(logrus.Fields(fields)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return l
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ func TestLogrus(t *testing.T) {
|
|||||||
l.WithField("abc", "bcd").Info("aaaa")
|
l.WithField("abc", "bcd").Info("aaaa")
|
||||||
l.WithField("bbb", "bbb").Info("bbbb")
|
l.WithField("bbb", "bbb").Info("bbbb")
|
||||||
l.WithField("ccc", "ccc").Info("cccc")
|
l.WithField("ccc", "ccc").Info("cccc")
|
||||||
|
|
||||||
|
l = l.WithField("o", "o")
|
||||||
|
l.WithField("z", "z").Info("abcd")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLevel(t *testing.T) {
|
func TestLevel(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user