TestCallerFile verifies that both text and JSON log paths report the user's call site, not an internal wrapper frame. This guards against skip-count drift when the core log method is refactored.
(t *testing.T)
| 133 | // user's call site, not an internal wrapper frame. This guards against |
| 134 | // skip-count drift when the core log method is refactored. |
| 135 | func TestCallerFile(t *testing.T) { |
| 136 | l := New("test") |
| 137 | l.SetHeader("${short_file}") |
| 138 | b := new(bytes.Buffer) |
| 139 | l.SetOutput(b) |
| 140 | l.SetLevel(DEBUG) |
| 141 | |
| 142 | b.Reset() |
| 143 | l.Info("text call") |
| 144 | assert.Contains(t, b.String(), "log_test.go", "text path should report caller file") |
| 145 | |
| 146 | b.Reset() |
| 147 | l.Infoj(JSON{"hello": "world"}) |
| 148 | assert.Contains(t, b.String(), "log_test.go", "JSON path should report caller file") |
| 149 | } |
| 150 | |
| 151 | func BenchmarkLog(b *testing.B) { |
| 152 | l := New("test") |
nothing calls this directly
no test coverage detected
searching dependent graphs…