logging: Catch errors when loading logging/config_file
This commit is contained in:
parent
3e259f1c00
commit
ede5b8abff
@ -90,6 +90,9 @@ Cleanups
|
|||||||
- The ``on_event`` handler in our listener helper now catches exceptions. This
|
- The ``on_event`` handler in our listener helper now catches exceptions. This
|
||||||
means that any errors in event handling won't crash the actor in question.
|
means that any errors in event handling won't crash the actor in question.
|
||||||
|
|
||||||
|
- Catch errors when loading :confval:`logging/config_file`.
|
||||||
|
(Fixes: :issue:`1320`)
|
||||||
|
|
||||||
Gapless
|
Gapless
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,8 @@ LOG_LEVELS = {
|
|||||||
TRACE_LOG_LEVEL = 5
|
TRACE_LOG_LEVEL = 5
|
||||||
logging.addLevelName(TRACE_LOG_LEVEL, 'TRACE')
|
logging.addLevelName(TRACE_LOG_LEVEL, 'TRACE')
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class DelayedHandler(logging.Handler):
|
class DelayedHandler(logging.Handler):
|
||||||
|
|
||||||
@ -54,8 +56,12 @@ def setup_logging(config, verbosity_level, save_debug_log):
|
|||||||
if config['logging']['config_file']:
|
if config['logging']['config_file']:
|
||||||
# Logging config from file must be read before other handlers are
|
# Logging config from file must be read before other handlers are
|
||||||
# added. If not, the other handlers will have no effect.
|
# added. If not, the other handlers will have no effect.
|
||||||
logging.config.fileConfig(config['logging']['config_file'],
|
try:
|
||||||
disable_existing_loggers=False)
|
path = config['logging']['config_file']
|
||||||
|
logging.config.fileConfig(path, disable_existing_loggers=False)
|
||||||
|
except Exception as e:
|
||||||
|
# Catch everything as logging does not specify what can go wrong.
|
||||||
|
logger.error('Loading logging config %r failed. %s', path, e)
|
||||||
|
|
||||||
setup_console_logging(config, verbosity_level)
|
setup_console_logging(config, verbosity_level)
|
||||||
if save_debug_log:
|
if save_debug_log:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user