MCPcopy
hub / github.com/op/go-logging / TestFormat

Function TestFormat

format_test.go:12–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestFormat(t *testing.T) {
13 backend := InitForTesting(DEBUG)
14
15 f, err := NewStringFormatter("%{shortfile} %{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}")
16 if err != nil {
17 t.Fatalf("failed to set format: %s", err)
18 }
19 SetFormatter(f)
20
21 log := MustGetLogger("module")
22 log.Debug("hello")
23
24 line := MemoryRecordN(backend, 0).Formatted(0)
25 if "format_test.go:24 1970-01-01T00:00:00 D 0001 module hello" != line {
26 t.Errorf("Unexpected format: %s", line)
27 }
28}
29
30func logAndGetLine(backend *MemoryBackend) string {
31 MustGetLogger("foo").Debug("hello")

Callers

nothing calls this directly

Calls 9

InitForTestingFunction · 0.85
NewStringFormatterFunction · 0.85
SetFormatterFunction · 0.85
MustGetLoggerFunction · 0.85
MemoryRecordNFunction · 0.85
FatalfMethod · 0.80
DebugMethod · 0.80
FormattedMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected