Skip to content

fix(logger): push extra keys to the end #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aws_lambda_powertools/logging/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _extract_log_keys(self, log_record: logging.LogRecord) -> Dict[str, Any]:
record_dict["asctime"] = self.formatTime(record=log_record, datefmt=self.datefmt)
extras = {k: v for k, v in record_dict.items() if k not in RESERVED_LOG_ATTRS}

formatted_log = {**extras}
formatted_log = {}

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

formatted_log.update(**extras)
return formatted_log

@staticmethod
Expand Down