Changes
This release add support for reusing Logger
across multiple files in your code base via the new child
parameter 🎉🎉🎉
Child Loggers will be named after the convention {service}.{filename}
- It now follows the Python Logging inheritance mechanics. Here's a code excerpt to demonstrate how this feature looks like:
app.py - Your typical parent logger will be at your Lambda function handler
# POWERTOOLS_SERVICE_NAME: "payment"
import shared # Creates a child logger named "payment.shared"
from aws_lambda_powertools import Logger
logger = Logger()
def handler(event, context):
shared.inject_payment_id(event) # highlight-line
logger.structure_logs(append=True, order_id=event["order_id"]) # highlight-line
...
shared.py - You can use Logger(child=True)
to explicit tell Logger this should be the child
# POWERTOOLS_SERVICE_NAME: "payment"
from aws_lambda_powertools import Logger
logger = Logger(child=True) # highlight-line
def inject_payment_id(event):
logger.structure_logs(append=True, payment_id=event["payment_id"])
🌟 Minor Changes
- feat: logger inheritance (#99) by @heitorlessa
Chore
- chore(deps): bump lodash from 4.17.15 to 4.17.19 in /docs (#93) by @dependabot