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

Function withLogger

common_test.go:37–41  ·  common_test.go::withLogger

Here specifically to introduce an easily-identifiable filename for testing stacktraces and caller skips.

(t testing.TB, e zapcore.LevelEnabler, opts []Option, f func(*Logger, *observer.ObservedLogs))

Source from the content-addressed store, hash-verified

35// Here specifically to introduce an easily-identifiable filename for testing
36// stacktraces and caller skips.
37func withLogger(t testing.TB, e zapcore.LevelEnabler, opts []Option, f func(*Logger, *observer.ObservedLogs)) {
38 fac, logs := observer.New(e)
39 log := New(fac, opts...)
40 f(log, logs)
41}
42
43func withSugar(t testing.TB, e zapcore.LevelEnabler, opts []Option, f func(*SugaredLogger, *observer.ObservedLogs)) {
44 withLogger(t, e, opts, func(logger *Logger, logs *observer.ObservedLogs) { f(logger.Sugar(), logs) })

Callers 15

TestReplaceGlobalsFunction · 0.70
TestNewStdLogFunction · 0.70
TestNewStdLogAtFunction · 0.70
TestNewStdLogAtPanicsFunction · 0.70
TestNewStdLogAtFatalFunction · 0.70
TestRedirectStdLogFunction · 0.70
TestRedirectStdLogCallerFunction · 0.70
TestRedirectStdLogAtFunction · 0.70
withSugarFunction · 0.70

Calls 2

NewFunction · 0.92
NewFunction · 0.70

Tested by

no test coverage detected