Use case
As a customer who uses canonical logging - aka wide logging - I would like to be able to clear any key I might have appended to the Logger instance regardless of me using the default formatter or the decorator - both of which either expose a method along these lines or can be configured to automatically clear state.
Solution/User Experience
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
logger = Logger()
def lambda_handler(event: dict, context: LambdaContext) -> str:
try:
logger.append_keys(order_id=event.get('order_id', None)
finally:
logger.info('CANONICAL')
logger.clear_state()
Alternative solutions
Acknowledgment
Use case
Note
This is a cross-language feature request that was originally brought up under aws-powertools/powertools-lambda-typescript#2337
As a customer who uses canonical logging - aka wide logging - I would like to be able to clear any key I might have appended to the Logger instance regardless of me using the default formatter or the decorator - both of which either expose a method along these lines or can be configured to automatically clear state.
Solution/User Experience
Alternative solutions
Acknowledgment