-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Expected Behaviour
As per documentation, using a custom logging formatter should bring standard keys like service
. Lambda context keys and custom keys are working just fine.
Example provided demonstrates that service
key no longer appears in the first output.
Current Behaviour
When using a custom logging formatter, Powertools Logger standard keys are not being included.
This was identified when re-creating examples, outputs, and improving code snippets in #1262.
Code snippet
from aws_lambda_powertools import Logger
from aws_lambda_powertools.logging.formatter import LambdaPowertoolsFormatter
class CustomFormatter(LambdaPowertoolsFormatter):
def serialize(self, log: dict) -> str:
"""Serialize final structured log dict to JSON str"""
log["event"] = log.pop("message") # rename message key to event
return self.json_serializer(log) # use configured json serializer
logger = Logger(service="payment", logger_formatter=CustomFormatter())
logger.info("hello")
logger_two = Logger(service="payment")
logger_two.info("hello")
Possible Solution
No response
Steps to Reproduce
Execute the code snippet locally, no need to deploy a Lambda function.
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
Lambda Layers
Debugging logs
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working