generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 454
Closed
Labels
Description
Expected Behaviour
According to the docs, we should be able to set the log level explicitly through the level
parameter to Logger
.
Current Behaviour
The level
parameter is properly set the first time you instantiate Logger
, but subsequent instantiations with the same service name will not set the log level. (It will always be the original value from the first instance.)
Code snippet
from aws_lambda_powertools import Logger
first = Logger(level="INFO")
second = Logger(level="DEBUG")
print(f"first level = {first.log_level}") # first level = 20
print(f"second level = {second.log_level}") # second level = 20. (Should be 10)
Possible Solution
In Logger._init_logger
, setLevel
should be called before the early return.
Steps to Reproduce
Run the following code:
from aws_lambda_powertools import Logger
first = Logger(level="INFO")
second = Logger(level="DEBUG")
print(f"first level = {first.log_level}") # first level = 20
print(f"second level = {second.log_level}") # second level = 20. (Should be 10)
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.8
Packaging format used
PyPi
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Closed