You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This would cause the error not all arguments converted during string formatting, which is because in the example, subsequent unnamed arguments are expected to be part of interpolated string for the custom message.
e.g.
log.error("some custom message with variable: %s", some_variable)
We can log just the exception without custom message:
try:
...
exceptExceptionase:
log.error(e)
however to log the exception with additional custom message, we should be doing:
log.exception("some message") is the equivalent to log.error("some message", exc_info=True), which having exc_info set to true causes the exception information to be added to the log message. Additionally, we can add stack_info=True to the logging parameters to show the unwound stack leading up to the logging call (not the same as exception stack trace).
The text was updated successfully, but these errors were encountered:
We're logging exceptions incorrectly in some areas of the code.
e.g.
This would cause the error
not all arguments converted during string formatting
, which is because in the example, subsequent unnamed arguments are expected to be part of interpolated string for the custom message.e.g.
We can log just the exception without custom message:
however to log the exception with additional custom message, we should be doing:
log.exception("some message")
is the equivalent tolog.error("some message", exc_info=True)
, which havingexc_info
set to true causes the exception information to be added to the log message. Additionally, we can addstack_info=True
to the logging parameters to show the unwound stack leading up to the logging call (not the same as exception stack trace).The text was updated successfully, but these errors were encountered: