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

Function TestLogCalldepth

log_test.go:15–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestLogCalldepth(t *testing.T) {
16 buf := &bytes.Buffer{}
17 SetBackend(NewLogBackend(buf, "", log.Lshortfile))
18 SetFormatter(MustStringFormatter("%{shortfile} %{level} %{message}"))
19
20 log := MustGetLogger("test")
21 log.Info("test filename")
22
23 parts := strings.SplitN(buf.String(), " ", 2)
24
25 // Verify that the correct filename is registered by the stdlib logger
26 if !strings.HasPrefix(parts[0], "log_test.go:") {
27 t.Errorf("incorrect filename: %s", parts[0])
28 }
29 // Verify that the correct filename is registered by go-logging
30 if !strings.HasPrefix(parts[1], "log_test.go:") {
31 t.Errorf("incorrect filename: %s", parts[1])
32 }
33}
34
35func c(log *Logger) { log.Info("test callpath") }
36func b(log *Logger) { c(log) }

Callers

nothing calls this directly

Calls 8

SetBackendFunction · 0.85
SetFormatterFunction · 0.85
MustStringFormatterFunction · 0.85
MustGetLoggerFunction · 0.85
InfoMethod · 0.80
StringMethod · 0.80
ErrorfMethod · 0.80
NewLogBackendFunction · 0.70

Tested by

no test coverage detected