structlog_config.levels#

Functions#

get_environment_log_level_as_string() → str

compare_log_levels(left, right) → int

Compare log levels using logging.getLevelNamesMapping for accurate int values.

resolve_level_name(level_name) → int | None

Translate a log level name to its numeric value

is_debug_level() → bool

Return True when the global logger is configured for DEBUG or TRACE verbosity.

Module Contents#

structlog_config.levels.get_environment_log_level_as_string() → str[source]#
structlog_config.levels.compare_log_levels(left: str, right: str) → int[source]#

Compare log levels using logging.getLevelNamesMapping for accurate int values.

Example: >>> compare_log_levels(“DEBUG”, “INFO”) -1 # DEBUG is less than INFO

Asks the question “Is INFO higher than DEBUG?”

structlog_config.levels.resolve_level_name(level_name: str) → int | None[source]#

Translate a log level name to its numeric value

structlog_config.levels.is_debug_level() → bool[source]#

Return True when the global logger is configured for DEBUG or TRACE verbosity.

Helpful for enabling debug flags on various 3rd party libraries. This makes it easy to turn on debug modes globally via LOG_LEVEL environment variable.