Replies: 3 comments 1 reply
-
Hey! Thanks for bringing this up. This messes up with the way Python logging finds who the caller is (the LOC that calls log.()), which then breaks the "location" key. This was fixed only in Python 3.8 if I'm most mistaken (stackLevel) parameter. As such, we'd need to create a patch and some internal changes for this to work. It's something I'd like to do in the future but takes some cycles to get it right. That said, structlog is an awesome library, why would you want to switch? Once we publish our roadmap this month I'll come back to this to think when would be a good timing. Thanks! |
Beta Was this translation helpful? Give feedback.
-
@heitorlessa : Thanks for adding this to the road map. Structlog is good but I like the features that the powertools tracing, metrics and logging libraries provide. Things like logging cold starts, easy metric creation etc. |
Beta Was this translation helpful? Give feedback.
-
Waaay later we added this feature ;) Closing: https://docs.powertools.aws.dev/lambda/python/latest/core/logger/#ephemeral-metadata |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a few Lambdas that use structlog which use this (multiple key=value passed as kwargs) construct for logging.
logger.info("Received order", order_id=order_id, customer_id=customer_id)
I'm looking to move to the powertools logger and per the documentation, I need to form a dictionary out of order_id and customer_id and pass it as an 'extra' :
logger.info("Received orde", extra={"order_id" : order_id, "customer_id" : customer_id})
Not only will this need a ton of refactoring, it also seems less intuitive. Is there a way I can make the aws-lambda-powertools-python logger work as is with my Lambdas?
Thanks
https://awslabs.github.io/aws-lambda-powertools-python/latest/core/logger/
extra parameter¶
New in 1.10.0
Extra parameter is available for all log levels' methods, as implemented in the standard logging library - e.g. logger.info, logger.warning.
It accepts any dictionary, and all keyword arguments will be added as part of the root structure of the logs for that log statement.
Beta Was this translation helpful? Give feedback.
All reactions