File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
aws_lambda_powertools/logging Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class Logger:
4444 ---------------------
4545 POWERTOOLS_SERVICE_NAME : str
4646 service name
47- LOG_LEVEL: str, int
47+ LOG_LEVEL: str
4848 logging level (e.g. INFO, DEBUG)
4949 POWERTOOLS_LOGGER_SAMPLE_RATE: float
5050 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():
333333
334334 # THEN we should be expected int (20, in this case)
335335 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