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

Function TestLoggerAddCallerFail

logger_test.go:739–760  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

737}
738
739func TestLoggerAddCallerFail(t *testing.T) {
740 errBuf := &ztest.Buffer{}
741 withLogger(t, DebugLevel, opts(AddCaller(), AddCallerSkip(1e3), ErrorOutput(errBuf)), func(log *Logger, logs *observer.ObservedLogs) {
742 log.Info("Failure.")
743 assert.Regexp(
744 t,
745 `Logger.check error: failed to get caller`,
746 errBuf.String(),
747 "Didn't find expected failure message.",
748 )
749 assert.Equal(
750 t,
751 logs.AllUntimed()[0].Message,
752 "Failure.",
753 "Expected original message to survive failures in runtime.Caller.")
754 assert.Equal(
755 t,
756 logs.AllUntimed()[0].Caller.Function,
757 "",
758 "Expected function name to be empty string.")
759 })
760}
761
762func TestLoggerReplaceCore(t *testing.T) {
763 replace := WrapCore(func(zapcore.Core) zapcore.Core {

Callers

nothing calls this directly

Calls 8

StringMethod · 0.95
optsFunction · 0.85
AddCallerFunction · 0.85
AddCallerSkipFunction · 0.85
ErrorOutputFunction · 0.85
AllUntimedMethod · 0.80
withLoggerFunction · 0.70
InfoMethod · 0.45

Tested by

no test coverage detected