-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easy to test Fatal logs without requiring indirection at the call site #846
Comments
The expectation in code that calls
If we allow users to override the behavior arbitrarily, there's no guarantee Perhaps a better choice is to allow choosing between pre-defined behaviors.
For This makes testing log.Fatal possible because one could do the following with
Or the following with ExitGoroutineOnFatal.
|
That seems reasonable, and would be enough for the test-cases I'm looking at. There's some cases cases where the test can't easily set up a Looking at the code for how the fatal is plumbed through, I think the pre-defined exit/panic behaviour would be easier to plumb through to the CheckedEntry as well. |
Fixes #846. There's currently no easy way to test Fatal from outside of zap, as it triggers an os.Exit(1). Add options to customize the behaviour (allowing for panic, or Goexit), which can be used with `recover()` in tests.
Fixes #846. There's currently no easy way to test Fatal from outside of zap, as it triggers an os.Exit(1). Add options to customize the behaviour (allowing for panic, or Goexit), which can be used with `recover()` in tests.
…-go#861) Fixes uber-go#846. There's currently no easy way to test Fatal from outside of zap, as it triggers an os.Exit(1). Add options to customize the behaviour (allowing for panic, or Goexit), which can be used with `recover()` in tests.
Related to #494
There's no clean way to test code that uses
Fatal
,Rather than exposing the internal/exit package, we could expose an option that overrides the exit function used by zap.
The text was updated successfully, but these errors were encountered: