From eea419c2f055f7c2cac0fe8297ca76c77af2e77a Mon Sep 17 00:00:00 2001 From: feliixx Date: Fri, 22 Mar 2024 16:39:42 +0100 Subject: [PATCH] LogstashFormatter: Move field_skip_set creation to __init__ 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 --- logstash_async/formatter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logstash_async/formatter.py b/logstash_async/formatter.py index cc9cf09..3f254b0 100644 --- a/logstash_async/formatter.py +++ b/logstash_async/formatter.py @@ -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: @@ -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"""