File tree 2 files changed +12
-1
lines changed
aws_lambda_powertools/logging
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class Logger:
44
44
---------------------
45
45
POWERTOOLS_SERVICE_NAME : str
46
46
service name
47
- LOG_LEVEL: str, int
47
+ LOG_LEVEL: str
48
48
logging level (e.g. INFO, DEBUG)
49
49
POWERTOOLS_LOGGER_SAMPLE_RATE: float
50
50
samping rate ranging from 0 to 1, 1 being 100% sampling
Original file line number Diff line number Diff line change @@ -333,3 +333,14 @@ def test_logger_level_as_int():
333
333
334
334
# THEN we should be expected int (20, in this case)
335
335
assert logger .level == logging .INFO
336
+
337
+
338
+ def test_logger_level_env_var_as_int (monkeypatch ):
339
+ # GIVEN Logger is initialized
340
+ # WHEN log level is explicitly defined via LOG_LEVEL env as int
341
+ # THEN Logger should propagate ValueError
342
+ # since env vars can only be string
343
+ # and '50' is not a correct log level
344
+ monkeypatch .setenv ("LOG_LEVEL" , 50 )
345
+ with pytest .raises (ValueError , match = "Unknown level: '50'" ):
346
+ Logger ()
You can’t perform that action at this time.
0 commit comments