Expected Behaviour
Due to internal logic exception and exception_name always get overridden.
The following statement should serialize the values provided:
logger.info("Report", extra={"exception": "Oops! That was not valid", "exception_name": "ValueError" })
logger.append_keys(exception="Oops! That was not valid", exception_name="ValueError")
logger.info("Report")
and produce an output like:
{
"level": "INFO",
"message": "Report",
"exception": "Oops! That was not valid",
"exception_name": "ValueError",
}
Current Behaviour
Due to internal logic these field get overridden with None:
{
"level": "INFO",
"message": "Report"
}
Code snippet
from aws_lambda_powertools import Logger
logger = Logger()
logger.info("Report", extra={"exception": "Oops! That was not valid", "exception_name": "ValueError"})
Possible Solution
Checking if these fields already exist on the formatted_log instead of always calling _extract_log_exception would fix this issue.
Steps to Reproduce
See code snippet section
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
No response
Expected Behaviour
Due to internal logic
exceptionandexception_namealways get overridden.The following statement should serialize the values provided:
and produce an output like:
Current Behaviour
Due to internal logic these field get overridden with None:
Code snippet
Possible Solution
Checking if these fields already exist on the
formatted_loginstead of always calling_extract_log_exceptionwould fix this issue.Steps to Reproduce
See code snippet section
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
No response