-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Make DPanic fatal in zaptest #1274
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1274 +/- ##
==========================================
- Coverage 98.08% 97.93% -0.16%
==========================================
Files 50 50
Lines 3240 3242 +2
==========================================
- Hits 3178 3175 -3
- Misses 53 57 +4
- Partials 9 10 +1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I agree that the zaptest logger should panic/run in development mode. This was an oversight. For opting out, we could maybe add a zaptest.LoggerOption that allows setting it to false?
zaptest.NewLogger(t) // will panic
zaptest.NewLogger(t, zaptest.Development(false)) // won't panic
There's a question of whether this is a breaking change, though.
Based on the intent of this API, I would consider this more a bugfix than a breaking change, but I'd like to hear thoughts on this from other maintainers.
IMO this is a breaking change in behavior; but since this will only affect tests I think it might be worth considering. Adding an option for opting out of the panic behavior would save many people from suddenly seeing a bunch of their tests break so I'm +1 on that suggestion. |
377e39f
to
800f9c8
Compare
WalkthroughA new configuration option was introduced to control whether the logger operates in zap's development mode. By default, the logger runs in development mode, but this can now be disabled using the newly added Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
So I've just added (yeah, sorry, I kinda forgot for two years) |
The intention of DPanic is to catch errors that should never happen. Unless you added zaptest.WrapOptions(zap.Development()), they were previously silently ignored. This is a breaking change. But you can opt out of this using zaptest.Development(false) option.
800f9c8
to
0c822a5
Compare
...and changed to |
Agree that this is worth changing as it only impacts tests, and it should have been this way from the start. |
The intention of
DPanic
is to catch errors that should never happen. Unless you addedzaptest.WrapOptions(zap.Development())
, they were previously silently ignored.This is a breaking change. But you can opt out of this using
zaptest.Development(false)
option.Summary by CodeRabbit