fields fix
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
3179852f9d
commit
5affde888c
@ -33,7 +33,7 @@ func (l *zeroLogger) Clone(opts ...logger.Option) logger.Logger {
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(&nl.opts.Options)
|
o(&nl.opts.Options)
|
||||||
}
|
}
|
||||||
|
nl.opts.Options.Fields = append(l.opts.Options.Fields, nl.opts.Options.Fields...)
|
||||||
_ = nl.Init()
|
_ = nl.Init()
|
||||||
return nl
|
return nl
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,9 @@ func TestFields(t *testing.T) {
|
|||||||
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
|
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
|
||||||
}
|
}
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
mnl := l.Fields(map[string]interface{}{"key": "val"})
|
mnl := nl.Fields("key1", "val1")
|
||||||
mnl.Infof(ctx, "message")
|
mnl.Infof(ctx, "message")
|
||||||
if bytes.Contains(buf.Bytes(), []byte(`"key":"val"`)) {
|
if !bytes.Contains(buf.Bytes(), []byte(`"key1":"val1"`)) || !bytes.Contains(buf.Bytes(), []byte(`"key":"val"`)) {
|
||||||
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
|
t.Fatalf("logger fields not works, buf contains: %s", buf.Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user