MCPcopy Index your code
hub / github.com/DoNewsCode/core / TestWithLevel

Function TestWithLevel

logging/log_test.go:14–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestWithLevel(t *testing.T) {
15 var buf bytes.Buffer
16 l := log.NewLogfmtLogger(&buf)
17 ll := WithLevel(l)
18 ll.Debug("hi")
19 // ensure the caller depth is correct
20 assert.Contains(t, buf.String(), "caller=log_test.go")
21 assert.Contains(t, buf.String(), "level=debug")
22
23 ll.Debugw("foo", "bar", "baz")
24 assert.Contains(t, buf.String(), "bar=baz")
25
26 ll.Debugf("foo%d", 1)
27 assert.Contains(t, buf.String(), "foo1")
28}
29
30func TestLevelFilter(t *testing.T) {
31 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 5

WithLevelFunction · 0.85
DebugMethod · 0.65
StringMethod · 0.65
DebugwMethod · 0.65
DebugfMethod · 0.65

Tested by

no test coverage detected