Skip to content

Commit

Permalink
Merge pull request #106 from heitorlessa/fix/regression-104
Browse files Browse the repository at this point in the history
fix: regression 104 and revert docstring
  • Loading branch information
heitorlessa authored Aug 14, 2020
2 parents 4573716 + 1f016f8 commit 24a3bdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws_lambda_powertools/logging/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Logger:
---------------------
POWERTOOLS_SERVICE_NAME : str
service name
LOG_LEVEL: str, int
LOG_LEVEL: str
logging level (e.g. INFO, DEBUG)
POWERTOOLS_LOGGER_SAMPLE_RATE: float
samping rate ranging from 0 to 1, 1 being 100% sampling
Expand Down
11 changes: 11 additions & 0 deletions tests/functional/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,14 @@ def test_logger_level_as_int():

# THEN we should be expected int (20, in this case)
assert logger.level == logging.INFO


def test_logger_level_env_var_as_int(monkeypatch):
# GIVEN Logger is initialized
# WHEN log level is explicitly defined via LOG_LEVEL env as int
# THEN Logger should propagate ValueError
# since env vars can only be string
# and '50' is not a correct log level
monkeypatch.setenv("LOG_LEVEL", 50)
with pytest.raises(ValueError, match="Unknown level: '50'"):
Logger()

0 comments on commit 24a3bdf

Please sign in to comment.