-
Notifications
You must be signed in to change notification settings - Fork 108
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
Stop using the logger.error("{}", str(exc))
idiom
#3099
Comments
If the string includes That's not a hypothetical; I started doing it after it tripped me up a couple of times. |
How will |
Well, if one of the arguments happens to be an empty set or dictionary....
|
I am not following. Can you give an example that actually fails using |
I can't give you a concrete example of real code off the top of my head, but I remember when Dave hit one. However, as a hypothetical, imagine that we have an exception object like this:
If the code does a As Dave said, this situation is easily finessed by calling |
If that was code under our control, shouldn't that be written where the formatting is done in the
If there are libraries we depend on, or the standard library does this, then that is another thing. Also, `self.logger.error("{}", exc) work, too, and avoids the string formatting when the log message won't be emitted. |
Yeah...and, it probably was. But, that doesn't have anything to do with whether we need the The point was that it wasn't unreasonable for the string to end up with a |
I personally see it to be very reasonable to expect exceptions to format without braces in the resulting string. But, I'd be willing to compromise with just seeing, |
I'm in at least 90% agreement with that...but, I don't want to be bitten in the rare case where having a
I think that the |
I'm not entirely certain anymore, but it's possible that our recent convention of using That is |
When we have a simple string to log, why not just log it?
For example, instead of
self.logger.error("{}", str(exc))
, just useself.logger.error(str(exc))
?Originally posted by @portante in #3091 (comment)
The text was updated successfully, but these errors were encountered: