MCPcopy
hub / github.com/uber-go/zap / TestStacktraceWithCallerSkip

Function TestStacktraceWithCallerSkip

stacktrace_ext_test.go:133–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestStacktraceWithCallerSkip(t *testing.T) {
134 withLogger(t, func(logger *zap.Logger, out *bytes.Buffer) {
135 logger = logger.WithOptions(zap.AddCallerSkip(2))
136 func() {
137 logger.Error("test log")
138 }()
139
140 require.NotContains(t, out.String(), "TestStacktraceWithCallerSkip.", "Should skip as requested by caller skip")
141 require.Contains(t, out.String(), "TestStacktraceWithCallerSkip", "Should not skip too much")
142 verifyNoZap(t, out.String())
143 })
144}
145
146// withLogger sets up a logger with a real encoder set up, so that any marshal functions are called.
147// The inbuilt observer does not call Marshal for objects/arrays, which we need for some tests.

Callers

nothing calls this directly

Calls 6

AddCallerSkipFunction · 0.92
verifyNoZapFunction · 0.85
withLoggerFunction · 0.70
WithOptionsMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected