-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Remove dead panic in Entry.Panic #1212
Conversation
[Entry.log itself panics][0] when the log level is set to PanicLevel, (and PanicLevel is always eneabled) so this second panic will never be reached. [0]: https://github.com/sirupsen/logrus/blob/8ae478eb8a850a54ea4915a2b572f377de1f9c7e/entry.go#L253
Hello @alecbz thanks for your contribution. However this change would make the code correctness dependant of the Panic specific value. I'm not sure it's a good idea to do that. |
@dgsb Can you elaborate? AFAICT right now this line is never run, so removing it should have no effect. Is there a situation where this line can be reached? edit: Oh, or are you talking about the test? That test is more-or-less a mirror of the |
I mean in term of maintainability, if someday we add a new level like
This would make the code incorrect and change its behaviour |
Well, first of all, Panicf doesn't have this direct But more to the point, what would you say the intended behavior should be if someone calls Panic on an EarthQuakeLevel logger? I'd imagine no-oping would be the correct approach, in which case the code as-is would be incorrect if a new EarthQuake level were added. If the idea is that we want to special-case |
Ok, let's merge that. Regarding hypothetical new level and side effect behaviour, you may want tool look at what the Fatal calls do. As a personal note, I'd rather not have level at all which trigger such side effects:
|
Ah yeah, the code there correctly calls Forcing a panic in all situations doesn't sound unreasonable, but yeah, if that's the direction we want to go, we should add the call to each of |
Entry.log itself panics when the log level is set to PanicLevel, (and
PanicLevel is always eneabled) so this second panic will never be reached.
This change is