-
Notifications
You must be signed in to change notification settings - Fork 428
Bug: Custom log formatter code not being reached #5503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hi @austin-ironside! Reading this now and trying to replicate the scenario in my environment. I'll get back to you with some updates as soon as possible. |
Thanks for the response! I was able to instantiate the CustomFormatter without having to alter the handlers directly. Not sure exactly where/when it started working. Might have been a SAM local build situation. The other issue of the lambda event being mutated from my changes, I worked around by using a
|
I don't think this was created by SAM or anything related to local build, but I'm glad you were able to make it work.
The payload doesn't change much, but yes, it's better to do a deep copy than a shallow copy, that way you'll be sure you're copying the entire structure.
I don't see any problem here. You're wrapping your main logic in a try/except block, so you can see when things go wrong and not raise exceptions. Thanks for reporting that it's working @austin-ironside! I'm closing this issue, feel free to reopen. |
|
Expected Behaviour
We have hundreds of lambda functions deployed with SAM. We globally set
POWERTOOLS_LOGGER_LOG_EVENT
toTrue
in order for the event of each invocation to be logged. In order to not log sensitve information, such as authoriztion headers from an APIGW event, I'm redacting certain fields due to security and in efforts to also reduce the overall size of the log in order to keep CloudWatch costs down.The custom logger should delete these certain fields from the event payload before being logged.
Current Behaviour
The
serialize()
method never gets reached and none of my logger logic is performed. When I import the logger in a python shell, it works as expected and the custom code is ran. However, my logger doesn't appear to call thedef serializer(self)
method unless I add these two lines below. Problem with this method is that the lambda event also gets modified. So when I try to redact the Authorization key in the headers, my lambda authorizer throws a key error because it's missing from the event payload now.:Code snippet
Lambda handler:
Custom Logger
Possible Solution
No response
Steps to Reproduce
Setup lambda function to use the CustomLogger as the
logger_formatter
and invoke the function locally or in the cloudPowertools for AWS Lambda (Python) version
3.2.0
AWS Lambda function runtime
3.9
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: