def _logging_config(config_parser, disable_existing_loggers=False):
"""
Helper that allows us to use an existing ConfigParser object to load logging
configurations instead of a filename.
Note: this code is essentially copy pasta from `logging.config.fileConfig` except
we skip loading the file.
"""
formatters = logging.config._create_formatters(config_parser)
# critical section
logging._acquireLock()
try:
logging._handlers.clear()
del logging._handlerList[:]
# Handlers add themselves to logging._handlers
handlers = logging.config._install_handlers(config_parser, formatters)
logging.config._install_loggers(config_parser, handlers, disable_existing_loggers)
finally:
logging._releaseLock()
评论列表
文章目录