diff --git a/.github/workflows/python_docs.yml b/.github/workflows/python_docs.yml index 86a2dd3c208..febee05519d 100644 --- a/.github/workflows/python_docs.yml +++ b/.github/workflows/python_docs.yml @@ -9,6 +9,8 @@ on: - master # Disabled until docs support versioning per branch/release # - develop + release: + types: [published] # update Docs upon new release jobs: docs: diff --git a/CHANGELOG.md b/CHANGELOG.md index be11a7b9867..655762a5611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.1] - 2020-08-14 +### Fixed +- **Logger**: Regression on `Logger` level not accepting `int` i.e. `Logger(level=logging.INFO)` + ## [1.1.0] - 2020-08-14 ### Added - **Logger**: Support for logger inheritance with `child` parameter diff --git a/aws_lambda_powertools/logging/logger.py b/aws_lambda_powertools/logging/logger.py index 1b4f3d8bcfe..2a4f2971248 100644 --- a/aws_lambda_powertools/logging/logger.py +++ b/aws_lambda_powertools/logging/logger.py @@ -53,7 +53,7 @@ class Logger: ---------- service : str, optional service name to be appended in logs, by default "service_undefined" - level : str, optional + level : str, int optional logging.level, by default "INFO" child: bool, optional create a child Logger named ., False by default @@ -132,8 +132,11 @@ def __getattr__(self, name): # https://github.com/awslabs/aws-lambda-powertools-python/issues/97 return getattr(self._logger, name) - def _get_log_level(self, level: str): + def _get_log_level(self, level: Union[str, int]) -> Union[str, int]: """ Returns preferred log level set by the customer in upper case """ + if isinstance(level, int): + return level + log_level: str = level or os.getenv("LOG_LEVEL") log_level = log_level.upper() if log_level is not None else logging.INFO diff --git a/pyproject.toml b/pyproject.toml index 978696e090a..ea087088993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aws_lambda_powertools" -version = "1.1.0" +version = "1.1.1" description = "Python utilities for AWS Lambda functions including but not limited to tracing, logging and custom metric" authors = ["Amazon Web Services"] classifiers=[ diff --git a/tests/functional/test_logger.py b/tests/functional/test_logger.py index 21f25125283..fa804a7c979 100644 --- a/tests/functional/test_logger.py +++ b/tests/functional/test_logger.py @@ -317,10 +317,19 @@ def test_logger_level_case_insensitive(stdout): assert logger.level == logging.INFO -def test_logger_level_not_set(stdout): +def test_logger_level_not_set(): # GIVEN a Loggers is initialized # WHEN no log level was passed - logger = Logger(level="info") + logger = Logger() # THEN we should default to INFO assert logger.level == logging.INFO + + +def test_logger_level_as_int(): + # GIVEN a Loggers is initialized + # WHEN log level is int + logger = Logger(level=logging.INFO) + + # THEN we should be expected int (20, in this case) + assert logger.level == logging.INFO