Skip to content

Case sensitive support for custom log levels #117

@paveldedik

Description

@paveldedik

To quote @radiophysicist

the problem is that logging doesn't prohibit to register custom log-level with name LeVeL and you try to look it for as LEVEL instead

i.e. we probably need update the method _get_level_value to account for custom log-levels with weird casings:

def _get_level_value(level_name: str) -> int:
"""Get numeric value for the log level name given."""
try:
# Try to get one of predefined log levels
return getattr(logging, level_name)
except AttributeError as e:
# May be it is a custom log level?
level = logging.getLevelName(level_name)
if isinstance(level, int):
return level
# Re-raise original error
raise ValueError(f"{level_name} is not a valid log level") from e

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions