Skip to content

Commit

Permalink
chore: Use public log levels mapping in Python 3.11+
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 31, 2025
1 parent ae84435 commit b7e4098
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion singer_sdk/plugin_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
extend_validator_with_defaults,
)

if sys.version_info >= (3, 11):
_LOG_LEVELS_MAPPING = logging.getLevelNamesMapping()
else:
_LOG_LEVELS_MAPPING = logging._nameToLevel # noqa: SLF001

if t.TYPE_CHECKING:
from jsonschema import ValidationError

Expand Down Expand Up @@ -137,7 +142,7 @@ def logger(cls) -> logging.Logger: # noqa: N805

logger = logging.getLogger(cls.name)

if log_level is not None and log_level.upper() in logging._levelToName.values(): # noqa: SLF001
if log_level is not None and log_level.upper() in _LOG_LEVELS_MAPPING:
logger.setLevel(log_level.upper())

return logger
Expand Down

0 comments on commit b7e4098

Please sign in to comment.