You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi folks. I'm a big fan of this library! But I always end up creating something to store the log levels in a reliable way. I'd like to write code like this, using a clear class offering autocomplete (potentially docstrings, etc):
And the LogLevel class is a collection like this with a nice parse option for verification and canonicalization (e.g. "error " --> "ERROR"):
classLogLevel:
debug="DEBUG"info="INFO"notice="NOTICE"warning="WARNING"error="ERROR"critical="CRITICAL"@staticmethoddefparse(level_text: str) ->str:
ifnotlevel_text:
raiseException("Level text must be specified")
level_text=level_text.upper().strip()
iflevel_text==LogLevel.debug:
returnLogLevel.debugeliflevel_text==LogLevel.info:
returnLogLevel.infoeliflevel_text==LogLevel.notice:
returnLogLevel.noticeeliflevel_text==LogLevel.warning:
returnLogLevel.warningeliflevel_text==LogLevel.error:
returnLogLevel.erroreliflevel_text==LogLevel.critical:
returnLogLevel.criticalelse:
raiseException(f"The level text {level_text} is not a supported log level.")
Would you be willing to adopt something like this?
The text was updated successfully, but these errors were encountered:
Hi folks. I'm a big fan of this library! But I always end up creating something to store the log levels in a reliable way. I'd like to write code like this, using a clear class offering autocomplete (potentially docstrings, etc):
Then we can use it like:
And the LogLevel class is a collection like this with a nice parse option for verification and canonicalization (e.g. "error " --> "ERROR"):
Would you be willing to adopt something like this?
The text was updated successfully, but these errors were encountered: