Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin D'Arcy committed Mar 12, 2024
1 parent f0a8be2 commit f62a549
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ Do not forget to add the `structlog.stdlib.add_log_level` and optionally the
as events. Default is `logging.WARNING`.
- `active` A flag to make this processor enabled/disabled.
- `as_context` Send `event_dict` as extra info to Sentry. Default is `True`.
- `ignore_breadcrumb_data` A list of data keys that will be excluded from
- `ignore_breadcrumb_data` A list of data keys that will be excluded from
[breadcrumb data](https://docs.sentry.io/platforms/python/enriching-events/breadcrumbs/#manual-breadcrumbs).
Defaults to keys which are already sent separately, i.e. `level`, `logger`,
`event` and `timestamp`. All other data in `event_dict` will be sent as
`event` and `timestamp`. All other data in `event_dict` will be sent as
breadcrumb data.
- `tag_keys` A list of keys. If any if these keys appear in `event_dict`,
the key and its corresponding value in `event_dict` will be used as Sentry
Expand Down
13 changes: 10 additions & 3 deletions structlog_sentry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def __init__(
event_level: int = logging.WARNING,
active: bool = True,
as_context: bool = True,
ignore_breadcrumb_data: Iterable[str] = ("level", "logger", "event", "timestamp"),
ignore_breadcrumb_data: Iterable[str] = (
"level",
"logger",
"event",
"timestamp",
),
tag_keys: list[str] | str | None = None,
ignore_loggers: Iterable[str] | None = None,
verbose: bool = False,
Expand Down Expand Up @@ -135,14 +140,16 @@ def _get_event_and_hint(self, event_dict: EventDict) -> tuple[dict, dict]:
return event, hint

def _get_breadcrumb_and_hint(self, event_dict: EventDict) -> tuple[dict, dict]:
data = {k: v for k, v in event_dict.items() if k not in self.ignore_breadcrumb_data}
data = {
k: v for k, v in event_dict.items() if k not in self.ignore_breadcrumb_data
}
event = {
"type": "log",
"level": event_dict.get("level"), # type: ignore
"category": event_dict.get("logger"),
"message": event_dict["event"],
"timestamp": event_dict.get("timestamp"),
"data": data
"data": data,
}

return event, {"log_record": event_dict}
Expand Down

0 comments on commit f62a549

Please sign in to comment.