config: Try to create the logs directory before setting up error logs.
This commit is contained in:
parent
31ec0564e7
commit
c1bc46cb2c
1 changed files with 14 additions and 8 deletions
|
@ -594,6 +594,12 @@ def setup_logging():
|
||||||
LOG_DIR = config.get('log_dir')
|
LOG_DIR = config.get('log_dir')
|
||||||
LOG_DIR = Path(LOG_DIR).expanduser() if LOG_DIR else xdg.DATA_HOME / 'logs'
|
LOG_DIR = Path(LOG_DIR).expanduser() if LOG_DIR else xdg.DATA_HOME / 'logs'
|
||||||
if config.get('log_errors'):
|
if config.get('log_errors'):
|
||||||
|
try:
|
||||||
|
LOG_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
except OSError:
|
||||||
|
# We can’t really log any error here, because logging isn’t setup yet.
|
||||||
|
pass
|
||||||
|
else:
|
||||||
LOGGING_CONFIG['root']['handlers'].append('error')
|
LOGGING_CONFIG['root']['handlers'].append('error')
|
||||||
LOGGING_CONFIG['handlers']['error'] = {
|
LOGGING_CONFIG['handlers']['error'] = {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
|
|
Loading…
Reference in a new issue