Closed
Description
When we use a custom formatter, inject_lambda_context with clear_state=True stopped having effect
Expected Behavior
The keys appended should be removed in clear_state=True and the context data should be kept. The custom Formatter should not impact this behavior
Current Behavior
When we use a custom formatter to obfuscate sensitive data in our logs, the flag clear_state=True stopped having effect, the context data is no longer logged and the keys appended was not removed in next hot execution. If clear_state is removed, the context data is logged normally
Steps to Reproduce (for bugs)
- Create a Formatter than override json_serializer_function
- Create a Logger object with this formatter
- Use the decorator inject_lambda_function(clear_state=True)
- Check the execution logs
Environment
- Powertools version used: 1.25.1
- Packaging format (Layers, PyPi): Layer
- AWS Lambda function runtime: python 3.8