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

Function TestSugarLnWithOptionsIncreaseLevel

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

Source from the content-addressed store, hash-verified

570}
571
572func TestSugarLnWithOptionsIncreaseLevel(t *testing.T) {
573 withSugar(t, DebugLevel, nil, func(logger *SugaredLogger, logs *observer.ObservedLogs) {
574 logger = logger.WithOptions(IncreaseLevel(WarnLevel))
575 logger.Infoln("logger.Infoln")
576 logger.Warnln("logger.Warnln")
577 logger.Errorln("logger.Errorln")
578 require.Equal(t, 2, logs.Len(), "expected only warn + error logs due to IncreaseLevel.")
579 assert.Equal(
580 t,
581 logs.AllUntimed()[0].Message,
582 "logger.Warnln",
583 "Expected first logged message to be warn level message",
584 )
585 })
586}
587
588func BenchmarkSugarSingleStrArg(b *testing.B) {
589 withSugar(b, InfoLevel, nil /* opts* */, func(log *SugaredLogger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 8

withSugarFunction · 0.85
IncreaseLevelFunction · 0.85
WarnlnMethod · 0.80
AllUntimedMethod · 0.80
WithOptionsMethod · 0.45
InfolnMethod · 0.45
ErrorlnMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected