Commit 49e60a28 authored by Luca Bigliardi's avatar Luca Bigliardi
Browse files

Use LogFileHandler conditionally in SetupLogging

Add a parameter to SetupLogging to use LogFileHandler (default is off)
Signed-off-by: default avatarLuca Bigliardi <>
Reviewed-by: default avatarMichael Hanselmann <>
parent de3b8e39
......@@ -2102,7 +2102,8 @@ class LogFileHandler(logging.FileHandler):
def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
multithreaded=False, syslog=constants.SYSLOG_USAGE):
multithreaded=False, syslog=constants.SYSLOG_USAGE,
"""Configures the logging module.
@type logfile: str
......@@ -2121,6 +2122,9 @@ def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
- if no, syslog is not used
- if yes, syslog is used (in addition to file-logging)
- if only, only syslog is used
@type console_logging: boolean
@param console_logging: if True, will use a FileHandler which falls back to
the system console if logging fails
@raise EnvironmentError: if we can't open the log file and
syslog/stderr logging is disabled
......@@ -2172,7 +2176,10 @@ def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
# the error if stderr_logging is True, and if false we re-raise the
# exception since otherwise we could run but without any logs at all
logfile_handler = logging.FileHandler(logfile)
if console_logging:
logfile_handler = LogFileHandler(logfile)
logfile_handler = logging.FileHandler(logfile)
if debug:
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