uber-go / zap

Blazing fast, structured, leveled logging in Go.
https://pkg.go.dev/go.uber.org/zap
MIT License
22.1k stars 1.44k forks source link

Support specifying a custom onPanic logger hook for tests #1415

Closed MKrupauskas closed 9 months ago

MKrupauskas commented 9 months ago

There can be complications when testing Panic/DPanic logs similarly to Fatal logs as described in https://github.com/uber-go/zap/issues/846.

For example, it's impossible to recover from a logger.Panic in a tests if that log is emitted in another go routine. This is exactly the case with our periodic runner library.

The best approach we came up with was extending zap to support passing a custom onPanic hook like we have for onFatal.