Skip to content

Commit

Permalink
Prevent global var from being discarded at shutdown (#2530)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Nov 24, 2023
1 parent a67914c commit 4e9d661
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ def setup_once():

def sentry_patched_callhandlers(self, record):
# type: (Any, LogRecord) -> Any
# keeping a local reference because the
# global might be discarded on shutdown
ignored_loggers = _IGNORED_LOGGERS

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:
if ignored_loggers is not None and record.name not in ignored_loggers:
integration = Hub.current.get_integration(LoggingIntegration)
if integration is not None:
integration._handle_record(record)
Expand Down

0 comments on commit 4e9d661

Please sign in to comment.