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

Function WithPanicHook

options.go:148–152  ·  view source on GitHub ↗

WithPanicHook sets a CheckWriteHook to run on Panic/DPanic logs. Zap will call this hook after writing a log statement with a Panic/DPanic level. For example, the following builds a logger that will exit the current goroutine after writing a Panic/DPanic log message, but it will not start a panic.

(hook zapcore.CheckWriteHook)

Source from the content-addressed store, hash-verified

146//
147// This is useful for testing Panic/DPanic log output.
148func WithPanicHook(hook zapcore.CheckWriteHook) Option {
149 return optionFunc(func(log *Logger) {
150 log.onPanic = hook
151 })
152}
153
154// OnFatal sets the action to take on fatal logs.
155//

Callers 1

TestLoggerCustomOnPanicFunction · 0.85

Calls 1

optionFuncFuncType · 0.70

Tested by 1

TestLoggerCustomOnPanicFunction · 0.68