Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case sensitive support for custom log levels #117

Open
paveldedik opened this issue Apr 20, 2023 · 0 comments
Open

Case sensitive support for custom log levels #117

paveldedik opened this issue Apr 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@paveldedik
Copy link
Collaborator

paveldedik commented Apr 20, 2023

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

@paveldedik paveldedik added the bug Something isn't working label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant