#397·zerolog

Add ability to override exit function

Author: nickpalmerCreated Jan 16, 2022Updated Jan 12, 2026

There should be a way to override the os.Exit() function call with a different exit handler.

zerolog.SetExitFunc(exit func(int) {})
// or even via a global
var ExitFunc = os.Exit()

This would allow people to do required cleanup such as closing a log file, or to write tests that call Fatal() and check that fatal was called.