Skip to content

Commit 58217e9

Browse files
committed
fix(logger): ensure custom key formats are kept when cleared
1 parent 8e5673a commit 58217e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

aws_lambda_powertools/logging/formatter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ def __init__(
127127

128128
super(LambdaPowertoolsFormatter, self).__init__(datefmt=self.datefmt)
129129

130-
keys_combined = {**self._build_default_keys(), **kwargs}
131-
self.log_format.update(**keys_combined)
130+
self.keys_combined = {**self._build_default_keys(), **kwargs}
131+
self.log_format.update(**self.keys_combined)
132132

133133
def serialize(self, log: Dict) -> str:
134134
"""Serialize structured log dict to JSON str"""
@@ -187,7 +187,7 @@ def remove_keys(self, keys: Iterable[str]):
187187

188188
def clear_state(self):
189189
self.log_format = dict.fromkeys(self.log_record_order)
190-
self.log_format.update(**self._build_default_keys())
190+
self.log_format.update(**self.keys_combined)
191191

192192
@staticmethod
193193
def _build_default_keys():

0 commit comments

Comments
 (0)