Description
Use case
In order to locate the source of a log message, the name of the standard library logger often gives a hint of where it's coming from, as it's a convention to use logging.getLogger(__name__)
to name the logger (see https://docs.python.org/3/howto/logging-cookbook.html#using-logging-in-multiple-modules for an example).
When following the FAQ guide step "How can I enable powertools logging for imported libraries? (permalink)"
(btw, logging.logger()
needs to be changed to logger.getLogger("my.precious.logger")
)
I will get a log message of
{
"level": "INFO",
"location": "<module>:12",
"message": "test message",
"timestamp": "2022-06-29 11:44:51,630+0000",
"service": "abc-def",
"sampling_rate": "0.1"
}
I am missing the name of the logger. In the above case it's not that difficult to locate where the log originated from, but take this example:
{
"level": "DEBUG",
"location": "parse:239",
"message": "Response headers: {'x-amzn-RequestId': '446775e4-6fbc-59a4-8c88-2ed253d21d82', 'Date': 'Wed, 29 Jun 2022 11:40:30 GMT', 'Content-Type': 'text/xml', 'Content-Length': '378'}",
"timestamp": "2022-06-29 11:40:30,927+0000",
"service": "abc-def",
"sampling_rate": "0.1",
"cold_start": true,
"function_name": "DevMyLambda-SFunction5A4552-bTFQOMC2LFTH",
"function_memory_size": "128",
"function_arn": "arn:aws:lambda:eu-west-1:0123456789:DevMyLambda-SFunction5A4552-bTFQOMC2LFTH",
"function_request_id": "9963e4d9-40fb-444a-9023-5ab5c973da5c",
"xray_trace_id": "1-62bc3a2b-6bb3afff1f9cf2d77b20c5fc"
}
It's difficult to see what library emitted that log message.
Solution/User Experience
Ideally, when aws-lambda-powertools-python is logging from standard library loggers, it should include the logger name as well.
Alternative solutions
Maybe this can be achieved using `LambdaPowertoolsFormatter` but I don't see the key available under https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/#standard-structured-keys
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Java, TypeScript