feat: add logc package, support AddGlobalFields for both logc and logx. (#2463)
* feat: add logc package * feat: add logc, add AddGlobalFields for both logc and logx * chore: add benchmarks * chore: add more tests * chore: simplify globalFields in logx * chore: remove outdated comments
This commit is contained in:
@@ -16,6 +16,9 @@ func TestNewWriter(t *testing.T) {
|
||||
w := NewWriter(&buf)
|
||||
w.Info(literal)
|
||||
assert.Contains(t, buf.String(), literal)
|
||||
buf.Reset()
|
||||
w.Debug(literal)
|
||||
assert.Contains(t, buf.String(), literal)
|
||||
}
|
||||
|
||||
func TestConsoleWriter(t *testing.T) {
|
||||
@@ -97,6 +100,7 @@ func TestNopWriter(t *testing.T) {
|
||||
assert.NotPanics(t, func() {
|
||||
var w nopWriter
|
||||
w.Alert("foo")
|
||||
w.Debug("foo")
|
||||
w.Error("foo")
|
||||
w.Info("foo")
|
||||
w.Severe("foo")
|
||||
@@ -123,6 +127,12 @@ func TestWritePlainAny(t *testing.T) {
|
||||
writePlainAny(nil, levelInfo, "foo")
|
||||
assert.Contains(t, buf.String(), "foo")
|
||||
|
||||
buf.Reset()
|
||||
writePlainAny(nil, levelDebug, make(chan int))
|
||||
assert.Contains(t, buf.String(), "unsupported type")
|
||||
writePlainAny(nil, levelDebug, 100)
|
||||
assert.Contains(t, buf.String(), "100")
|
||||
|
||||
buf.Reset()
|
||||
writePlainAny(nil, levelError, make(chan int))
|
||||
assert.Contains(t, buf.String(), "unsupported type")
|
||||
|
||||
Reference in New Issue
Block a user