Skip to content

Commit

Permalink
LogstashFormatter: Move field_skip_set creation to __init__
Browse files Browse the repository at this point in the history
Commit baf2118 introduced a new set `field_skip_set` to store the fields to
skip, unfortunately this field is created too early, causing modification
of `FORMATTER_RECORD_FIELD_SKIP_LIST` by library users to be ignored.
Let's create the field at the end of __init__ instead to fix the regression.

Fixes #96
  • Loading branch information
feliixx committed Mar 22, 2024
1 parent 49635e1 commit eea419c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion logstash_async/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class LogstashFormatter(logging.Formatter):

_basic_data_types = (type(None), bool, str, int, float)

field_skip_set = set(constants.FORMATTER_RECORD_FIELD_SKIP_LIST)
top_level_field_set = set(constants.FORMATTER_LOGSTASH_MESSAGE_FIELD_LIST)

class MessageSchema:
Expand Down Expand Up @@ -89,6 +88,8 @@ def __init__(
self._prefetch_logsource()
self._prefetch_program_name()

self.field_skip_set = set(constants.FORMATTER_RECORD_FIELD_SKIP_LIST)

# ----------------------------------------------------------------------
def _prefetch_interpreter(self):
"""Override when needed"""
Expand Down

0 comments on commit eea419c

Please sign in to comment.