10000 Regression of support for log level constants · Issue #104 · aws-powertools/powertools-lambda-python · GitHub
[go: up one dir, main page]

Skip to content
Regression of support for log level constants #104
Closed
@zroger

Description

@zroger

Before #99 it was possible to pass a logging constant like logging.INFO to the Logger constructor. After #99, I get this exception: AttributeError: 'int' object has no attribute 'upper' from logging/logger.py:122.

The docstrings are also confusing, since the environment variable says it accepts and integer or a string, but the constructor parameter is a string.

Expected Behavior

  • The Logger constructor should accept logging constants (integers) as well as strings.
  • The environment variable and constructor arg for log level should be consistent
  • The docstrings should be consistent with the code

Current Behavior

When an integer is passed, there is an AttributeError.

Steps to Reproduce (for bugs)

>>> import logging
>>> from aws_lambda_powertools import Logger
>>> Logger(service="demo", level=logging.INFO)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/aws_lambda_powertools/logging/logger.py", line 122, in __init__
    self.log_level = self._get_log_level(level)
  File "/usr/local/lib/python3.8/site-packages/aws_lambda_powertools/logging/logger.py", line 138, in _get_log_level
    log_level = log_level.upper() if log_level is not None else logging.INFO
AttributeError: 'int' object has no attribute 'upper'

Environment

  • Powertools version used: 1.1.0
  • Packaging format (Layers, PyPi):
  • AWS Lambda function runtime: python3.8
  • Debugging logs

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneed-more-informationPending information to continue

Type

No type

Projects

Status

Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0