Skip to content

Commit ba68bc8

Browse files
authored
fix(idempotency): sorting keys before hashing (#722)
1 parent 1845053 commit ba68bc8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: aws_lambda_powertools/logging/formatter.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def _extract_log_keys(self, log_record: logging.LogRecord) -> Dict[str, Any]:
222222
record_dict["asctime"] = self.formatTime(record=log_record, datefmt=self.datefmt)
223223
extras = {k: v for k, v in record_dict.items() if k not in RESERVED_LOG_ATTRS}
224224

225-
formatted_log = {**extras}
225+
formatted_log = {}
226226

227227
# Iterate over a default or existing log structure
228228
# then replace any std log attribute e.g. '%(level)s' to 'INFO', '%(process)d to '4773'
@@ -233,6 +233,7 @@ def _extract_log_keys(self, log_record: logging.LogRecord) -> Dict[str, Any]:
233233
else:
234234
formatted_log[key] = value
235235

236+
formatted_log.update(**extras)
236237
return formatted_log
237238

238239
@staticmethod

0 commit comments

Comments
 (0)