Skip to content

Commit 24a3bdf

Browse files
authored
Merge pull request #106 from heitorlessa/fix/regression-104
fix: regression 104 and revert docstring
2 parents 4573716 + 1f016f8 commit 24a3bdf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

aws_lambda_powertools/logging/logger.py

+1-1
Original file line numberDiff line numberDiff 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

tests/functional/test_logger.py

+11
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)