Hi!
I am using the aws-lambda-powertools-python logger for a number of projects but also have existing deployments using structured JSON logging implemented with a custom logger. Our custom logger supports the Python logging extra parameter to supply custom attributes. It would be great if the aws-lambda-powertools-python formatter supported custom attributes so we can take advantage of structured logging for additional attributes.
Example
from aws_lambda_powertools.logging import Logger
logger = Logger()
logger.info('Put aggregation result', extra={'key': 'results/sum.csv', 'size': 130425})
Current output:
{
"level": "INFO",
"location": "<module>:5",
"message": "Put aggregation result",
"timestamp": "2020-12-23 11:00:47,695",
"service": "service_undefined",
"sampling_rate": 0
}
Desired output:
{
"level": "INFO",
"location": "<module>:5",
"message": "Put aggregation result",
"timestamp": "2020-12-23 11:00:47,695",
"service": "service_undefined",
"sampling_rate": 0,
"key": "results/sum.csv",
"size": 130425
}
This enables us to do effective log queries, filtering and stats using CloudWatch Logs Insights.
For reference:
Is this something that you would consider supporting?
Hi!
I am using the
aws-lambda-powertools-pythonlogger for a number of projects but also have existing deployments using structured JSON logging implemented with a custom logger. Our custom logger supports the Python loggingextraparameter to supply custom attributes. It would be great if theaws-lambda-powertools-pythonformatter supported custom attributes so we can take advantage of structured logging for additional attributes.Example
Current output:
Desired output:
This enables us to do effective log queries, filtering and stats using CloudWatch Logs Insights.
For reference:
python-json-loggersupport custom attributes usingextra- https://github.com/madzak/python-json-loggerextrakeyword argument to add custom attributes to theLogRecordis covered here: https://docs.python.org/3/library/logging.htmlIs this something that you would consider supporting?