logging: Report stack_info on logging.exception calls.

The exception trace only goes from where the exception was thrown up
to where the `logging.exception` call is; any context as to where
_that_ was called from is lost, unless `stack_info` is passed as well.
Having the stack is particularly useful for Sentry exceptions, which
gain the full stack trace.

Add `stack_info=True` on all `logging.exception` calls with a
non-trivial stack; we omit `wsgi.py`.  Adjusts tests to match.
This commit is contained in:
Alex Vandiver
2020-08-10 18:19:00 -07:00
committed by Tim Abbott
parent e3a093b73f
commit 2928bbc8bd
15 changed files with 29 additions and 22 deletions

View File

@@ -34,7 +34,7 @@ if settings.USING_RABBITMQ:
def handle_callback_exception(callback: Callable[..., Any]) -> None:
logging.exception("Exception in callback")
logging.exception("Exception in callback", stack_info=True)
app_log.error("Exception in callback %r", callback, exc_info=True)
class Command(BaseCommand):