config: Try to create the logs directory before setting up error logs.

This commit is contained in:
Emmanuel Gil Peyrot 2018-07-19 12:03:40 +02:00
parent 31ec0564e7
commit c1bc46cb2c

View file

@ -594,6 +594,12 @@ def setup_logging():
LOG_DIR = config.get('log_dir')
LOG_DIR = Path(LOG_DIR).expanduser() if LOG_DIR else xdg.DATA_HOME / 'logs'
if config.get('log_errors'):
try:
LOG_DIR.mkdir(parents=True, exist_ok=True)
except OSError:
# We cant really log any error here, because logging isnt setup yet.
pass
else:
LOGGING_CONFIG['root']['handlers'].append('error')
LOGGING_CONFIG['handlers']['error'] = {
'level': 'ERROR',