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

Function TestLoggerDPanic

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

Source from the content-addressed store, hash-verified

516}
517
518func TestLoggerDPanic(t *testing.T) {
519 withLogger(t, DebugLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) {
520 assert.NotPanics(t, func() { logger.DPanic("") })
521 assert.Equal(
522 t,
523 []observer.LoggedEntry{{Entry: zapcore.Entry{Level: DPanicLevel}, Context: []Field{}}},
524 logs.AllUntimed(),
525 "Unexpected log output from DPanic in production mode.",
526 )
527 })
528 withLogger(t, DebugLevel, opts(Development()), func(logger *Logger, logs *observer.ObservedLogs) {
529 assert.Panics(t, func() { logger.DPanic("") })
530 assert.Equal(
531 t,
532 []observer.LoggedEntry{{Entry: zapcore.Entry{Level: DPanicLevel}, Context: []Field{}}},
533 logs.AllUntimed(),
534 "Unexpected log output from DPanic in development mode.",
535 )
536 })
537}
538
539func TestLoggerNoOpsDisabledLevels(t *testing.T) {
540 withLogger(t, WarnLevel, nil, func(logger *Logger, logs *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 5

optsFunction · 0.85
DevelopmentFunction · 0.85
AllUntimedMethod · 0.80
withLoggerFunction · 0.70
DPanicMethod · 0.45

Tested by

no test coverage detected