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

Function TestLoggerIncreaseLevel

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

Source from the content-addressed store, hash-verified

772}
773
774func TestLoggerIncreaseLevel(t *testing.T) {
775 withLogger(t, DebugLevel, opts(IncreaseLevel(WarnLevel)), func(logger *Logger, logs *observer.ObservedLogs) {
776 logger.Info("logger.Info")
777 logger.Warn("logger.Warn")
778 logger.Error("logger.Error")
779 require.Equal(t, 2, logs.Len(), "expected only warn + error logs due to IncreaseLevel.")
780 assert.Equal(
781 t,
782 logs.AllUntimed()[0].Message,
783 "logger.Warn",
784 "Expected first logged message to be warn level message",
785 )
786 })
787}
788
789func TestLoggerHooks(t *testing.T) {
790 hook, seen := makeCountingHook()

Callers

nothing calls this directly

Calls 8

optsFunction · 0.85
IncreaseLevelFunction · 0.85
AllUntimedMethod · 0.80
withLoggerFunction · 0.70
InfoMethod · 0.45
WarnMethod · 0.45
ErrorMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected