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

Function TestLoggerWriteFailure

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

Source from the content-addressed store, hash-verified

588}
589
590func TestLoggerWriteFailure(t *testing.T) {
591 errSink := &ztest.Buffer{}
592 logger := New(
593 zapcore.NewCore(
594 zapcore.NewJSONEncoder(NewProductionConfig().EncoderConfig),
595 zapcore.Lock(zapcore.AddSync(ztest.FailWriter{})),
596 DebugLevel,
597 ),
598 ErrorOutput(errSink),
599 )
600
601 logger.Info("foo")
602 // Should log the error.
603 assert.Regexp(t, `write error: failed`, errSink.Stripped(), "Expected to log the error to the error output.")
604 assert.True(t, errSink.Called(), "Expected logging an internal error to call Sync the error sink.")
605}
606
607func TestLoggerSync(t *testing.T) {
608 withLogger(t, DebugLevel, nil, func(logger *Logger, _ *observer.ObservedLogs) {

Callers

nothing calls this directly

Calls 10

StrippedMethod · 0.95
NewCoreFunction · 0.92
NewJSONEncoderFunction · 0.92
LockFunction · 0.92
AddSyncFunction · 0.92
NewProductionConfigFunction · 0.85
ErrorOutputFunction · 0.85
CalledMethod · 0.80
NewFunction · 0.70
InfoMethod · 0.45

Tested by

no test coverage detected