(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func 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 | |
| 35 | func c(log *Logger) { log.Info("test callpath") } |
| 36 | func b(log *Logger) { c(log) } |
nothing calls this directly
no test coverage detected