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

Function TestLoggerLogLevels

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

Source from the content-addressed store, hash-verified

456}
457
458func TestLoggerLogLevels(t *testing.T) {
459 withLogger(t, DebugLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) {
460 levels := []zapcore.Level{
461 DebugLevel,
462 InfoLevel,
463 WarnLevel,
464 ErrorLevel,
465 DPanicLevel,
466 }
467 for i, level := range levels {
468 logger.Log(level, "")
469 output := logs.AllUntimed()
470 assert.Equal(t, i+1, len(output), "Unexpected number of logs.")
471 assert.Equal(t, 0, len(output[i].Context), "Unexpected context on first log.")
472 assert.Equal(
473 t,
474 zapcore.Entry{Level: level},
475 output[i].Entry,
476 "Unexpected output from %s-level logger method.", level)
477 }
478 })
479}
480
481func TestLoggerAlwaysPanics(t *testing.T) {
482 // Users can disable writing out panic-level logs, but calls to logger.Panic()

Callers

nothing calls this directly

Calls 3

AllUntimedMethod · 0.80
withLoggerFunction · 0.70
LogMethod · 0.45

Tested by

no test coverage detected