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

Function TestSugarAddCallerFail

sugar_test.go:538–554  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

536}
537
538func TestSugarAddCallerFail(t *testing.T) {
539 errBuf := &ztest.Buffer{}
540 withSugar(t, DebugLevel, opts(AddCaller(), AddCallerSkip(1e3), ErrorOutput(errBuf)), func(log *SugaredLogger, logs *observer.ObservedLogs) {
541 log.Info("Failure.")
542 assert.Regexp(
543 t,
544 `Logger.check error: failed to get caller`,
545 errBuf.String(),
546 "Didn't find expected failure message.",
547 )
548 assert.Equal(
549 t,
550 logs.AllUntimed()[0].Message,
551 "Failure.",
552 "Expected original message to survive failures in runtime.Caller.")
553 })
554}
555
556func TestSugarWithOptionsIncreaseLevel(t *testing.T) {
557 withSugar(t, DebugLevel, nil, func(logger *SugaredLogger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected