Commit aa0cc3e5 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

utils.log: Restrict I/O error handling coverage



The I/O error will occur while opening the file, not while adding
and configuring the handler.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent d24bc000
......@@ -229,16 +229,16 @@ def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
logfile_handler = _LogHandler(open(constants.DEV_CONSOLE, "a"), logfile)
else:
logfile_handler = _ReopenableLogHandler(logfile)
logfile_handler.setFormatter(formatter)
if debug:
logfile_handler.setLevel(logging.DEBUG)
else:
logfile_handler.setLevel(logging.INFO)
root_logger.addHandler(logfile_handler)
except EnvironmentError:
if stderr_logging or syslog == constants.SYSLOG_YES:
logging.exception("Failed to enable logging to file '%s'", logfile)
else:
# we need to re-raise the exception
raise
logfile_handler.setFormatter(formatter)
if debug:
logfile_handler.setLevel(logging.DEBUG)
else:
logfile_handler.setLevel(logging.INFO)
root_logger.addHandler(logfile_handler)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment