Skip to content

Commit

Permalink
fix(logging): An error should not have its own breadcrumb (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Nov 30, 2018
1 parent 30d6a38 commit 39b9438
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ def setup_once():
old_callhandlers = logging.Logger.callHandlers

def sentry_patched_callhandlers(self, record):
# This check is done twice, once also here before we even get
# the integration. Otherwise we have a high chance of getting
# into a recursion error when the integration is resolved
# (this also is slower).
if record.name not in _IGNORED_LOGGERS:
integration = Hub.current.get_integration(LoggingIntegration)
if integration is not None:
integration._handle_record(record)
return old_callhandlers(self, record)
try:
return old_callhandlers(self, record)
finally:
# This check is done twice, once also here before we even get
# the integration. Otherwise we have a high chance of getting
# into a recursion error when the integration is resolved
# (this also is slower).
if record.name not in _IGNORED_LOGGERS:
integration = Hub.current.get_integration(LoggingIntegration)
if integration is not None:
integration._handle_record(record)

logging.Logger.callHandlers = sentry_patched_callhandlers

Expand Down

0 comments on commit 39b9438

Please sign in to comment.