(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | |
| 30 | func logAndGetLine(backend *MemoryBackend) string { |
| 31 | MustGetLogger("foo").Debug("hello") |
nothing calls this directly
no test coverage detected