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
In simple scripts like the above, I would like to configure the log level based on a string.
Configuring a FilteringBoundLogger needs much code though:
Exposing NAME_TO_LEVEL from _log_levels would reduce the above code to
importosimportstructlog_loglevel_name=os.environ.get('LOGLEVEL', 'WARNING').upper()
# Note: structlog.NAME_TO_LEVEL does not currently exist in structlog._loglevel=structlog.NAME_TO_LEVEL.get(_loglevel_name)
structlog.configure(
wrapper_class=structlog.make_filtering_bound_logger(_loglevel),
)
log=structlog.get_logger()
use-case
Simple one-off scripts like this:
problem
In simple scripts like the above, I would like to configure the log level based on a string.
Configuring a FilteringBoundLogger needs much code though:
options
expose
NAME_TO_LEVEL
Exposing
NAME_TO_LEVEL
from_log_levels
would reduce the above code toadd
structlog.basic_config
This is what I would love to have:
remarks
Maybe there is a simpler way that I could not find in the docs.
Anyway, thanks for this great tool Hynek! :)
The text was updated successfully, but these errors were encountered: