From fbe395746f523722f6a0cc1c22cd5114d86c495f Mon Sep 17 00:00:00 2001 From: Gagan Chawla Date: Sat, 13 Apr 2019 16:55:04 +0530 Subject: [PATCH 1/3] Fix for 'data' key in logger's extra --- sentry_sdk/integrations/logging.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index a8b02b588e..0d75579eb9 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -134,11 +134,19 @@ def _logging_to_event_level(levelname): def _extra_from_record(record): # type: (LogRecord) -> Dict[str, None] - return { - k: v - for k, v in vars(record).items() - if k not in COMMON_RECORD_ATTRS and not k.startswith("_") - } + extra = getattr(record, 'data', None) + if not isinstance(extra, dict): + if extra: + extra = {'data': extra} + else: + extra = {} + + for k, v in vars(record).items(): + if k in COMMON_RECORD_ATTRS or k.startswith("_"): + continue + extra[k] = v + + return extra class EventHandler(logging.Handler, object): From 835c7334e41303f24c04e63dc165964cd89457b3 Mon Sep 17 00:00:00 2001 From: Gagan Chawla Date: Mon, 15 Apr 2019 15:17:05 +0530 Subject: [PATCH 2/3] Revert "Fix for 'data' key in logger's extra" This reverts commit fbe395746f523722f6a0cc1c22cd5114d86c495f. --- sentry_sdk/integrations/logging.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index 0d75579eb9..a8b02b588e 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -134,19 +134,11 @@ def _logging_to_event_level(levelname): def _extra_from_record(record): # type: (LogRecord) -> Dict[str, None] - extra = getattr(record, 'data', None) - if not isinstance(extra, dict): - if extra: - extra = {'data': extra} - else: - extra = {} - - for k, v in vars(record).items(): - if k in COMMON_RECORD_ATTRS or k.startswith("_"): - continue - extra[k] = v - - return extra + return { + k: v + for k, v in vars(record).items() + if k not in COMMON_RECORD_ATTRS and not k.startswith("_") + } class EventHandler(logging.Handler, object): From 40d073a8149fdba94230e678ef4ec5d029bfaf61 Mon Sep 17 00:00:00 2001 From: Gagan Chawla Date: Mon, 15 Apr 2019 16:30:43 +0530 Subject: [PATCH 3/3] Removed `data` from constant --- sentry_sdk/integrations/logging.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sentry_sdk/integrations/logging.py b/sentry_sdk/integrations/logging.py index a8b02b588e..60fba0dc74 100644 --- a/sentry_sdk/integrations/logging.py +++ b/sentry_sdk/integrations/logging.py @@ -106,7 +106,6 @@ def _logging_to_event_level(levelname): ( "args", "created", - "data", "exc_info", "exc_text", "filename",