(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestBackendFormatter(t *testing.T) { |
| 146 | InitForTesting(DEBUG) |
| 147 | |
| 148 | // Create two backends and wrap one of the with a backend formatter |
| 149 | b1 := NewMemoryBackend(1) |
| 150 | b2 := NewMemoryBackend(1) |
| 151 | |
| 152 | f := MustStringFormatter("%{level} %{message}") |
| 153 | bf := NewBackendFormatter(b2, f) |
| 154 | |
| 155 | SetBackend(b1, bf) |
| 156 | |
| 157 | log := MustGetLogger("module") |
| 158 | log.Info("foo") |
| 159 | if "foo" != getLastLine(b1) { |
| 160 | t.Errorf("Unexpected line: %s", getLastLine(b1)) |
| 161 | } |
| 162 | if "INFO foo" != getLastLine(b2) { |
| 163 | t.Errorf("Unexpected line: %s", getLastLine(b2)) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | func BenchmarkStringFormatter(b *testing.B) { |
| 168 | fmt := "%{time:2006-01-02T15:04:05} %{level:.1s} %{id:04d} %{module} %{message}" |
nothing calls this directly
no test coverage detected