INNER CODE UNIT · Python
config_root_logger
bobbui/json-logging-python · json_logging/__init__.py:57
def config_root_logger():
"""
Make all root logger handlers produce JSON format.
init_*() already converts the root logger handlers that exist at initialisation time. Call this
when a handler with a plain text formatter is attached to the root logger afterwards, for example
by a logging.basicConfig() call made after initialisation. The handler must exist before this is
called.
"""
if not logging.root.handlers:
_logger.error(
"No logging handlers found for root logger. Please made sure that you call this after you called "
"logging.basicConfig() or logging.getLogger()")
return
if ENABLE_JSON_LOGGING:
ENABLE_JSON_LOGGING_DEBUG and _logger.debug("Update root logger to using JSONLogFormatter")