logging: Catch errors when loading logging/config_file

(cherry picked from commit ede5b8abff)
This commit is contained in:
Thomas Adamcik 2015-12-05 22:44:39 +01:00 committed by Stein Magnus Jodal
parent d85a3870d0
commit 92bb9b9b77
2 changed files with 11 additions and 2 deletions

View File

@ -23,6 +23,9 @@ Bug fix release.
the player is paused, the new track would not be added to the history or
marked as currently playing. (Fixes: :issue:`1352`)
- Main: Catch errors when loading :confval:`logging/config_file`. (Fixes:
:issue:`1320`)
v1.1.1 (2015-09-14)
===================

View File

@ -19,6 +19,8 @@ LOG_LEVELS = {
TRACE_LOG_LEVEL = 5
logging.addLevelName(TRACE_LOG_LEVEL, 'TRACE')
logger = logging.getLogger(__name__)
class DelayedHandler(logging.Handler):
@ -54,8 +56,12 @@ def setup_logging(config, verbosity_level, save_debug_log):
if config['logging']['config_file']:
# Logging config from file must be read before other handlers are
# added. If not, the other handlers will have no effect.
logging.config.fileConfig(config['logging']['config_file'],
disable_existing_loggers=False)
try:
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)
if save_debug_log: