MCPcopy Create free account
hub / github.com/labstack/gommon / TestCallerFile

Function TestCallerFile

log/log_test.go:135–149  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

133// user's call site, not an internal wrapper frame. This guards against
134// skip-count drift when the core log method is refactored.
135func 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
151func BenchmarkLog(b *testing.B) {
152 l := New("test")

Callers

nothing calls this directly

Calls 8

SetHeaderMethod · 0.80
SetLevelMethod · 0.80
ResetMethod · 0.80
InfoMethod · 0.80
StringMethod · 0.80
InfojMethod · 0.80
NewFunction · 0.70
SetOutputMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…