simplify log file error handling

This commit is contained in:
Brad Warren 2016-07-08 12:53:09 -07:00
parent 40449ed274
commit 9ae755ef4c

View file

@ -2,7 +2,6 @@
from __future__ import print_function
import atexit
import dialog
import errno
import functools
import logging.handlers
import os
@ -602,13 +601,8 @@ def setup_log_file_handler(config, logfile, fmt):
try:
handler = logging.handlers.RotatingFileHandler(
log_file_path, maxBytes=2 ** 20, backupCount=10)
except IOError as e:
if e.errno == errno.EACCES:
msg = ("Access denied writing to {0}. To run as non-root, set " +
"--logs-dir, --config-dir, --work-dir to writable paths.")
raise errors.Error(msg.format(log_file_path))
else:
raise
except IOError:
raise errors.Error(_PERM_ERR_FMT.format(log_file_path))
# rotate on each invocation, rollover only possible when maxBytes
# is nonzero and backupCount is nonzero, so we set maxBytes as big
# as possible not to overrun in single CLI invocation (1MB).