Closed
Description
Use case
I wan't to add variables to the logger for the duration of a request and get clean up for free without needing to explicitly call delete.
This is similar to https://www.structlog.org/en/stable/api.html#structlog.contextvars.bound_contextvars
Solution/User Experience
@contextmanager
def bind(self, **args):
logger_instance.append_keys(**args)
yield logger_instance
logger_instance.remove_keys(args.keys())
with logger.bind(user_id=123):
perform_operation():
Alternative solutions
No response
Acknowledgment
- This feature request meets Lambda Powertools Tenets
- Should this be considered in other Lambda Powertools languages? i.e. Java, TypeScript
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped