Revision 49e60a28

b/lib/utils.py
2102 2102

  
2103 2103

  
2104 2104
def SetupLogging(logfile, debug=0, stderr_logging=False, program="",
2105
                 multithreaded=False, syslog=constants.SYSLOG_USAGE):
2105
                 multithreaded=False, syslog=constants.SYSLOG_USAGE,
2106
                 console_logging=False):
2106 2107
  """Configures the logging module.
2107 2108

  
2108 2109
  @type logfile: str
......
2121 2122
      - if no, syslog is not used
2122 2123
      - if yes, syslog is used (in addition to file-logging)
2123 2124
      - if only, only syslog is used
2125
  @type console_logging: boolean
2126
  @param console_logging: if True, will use a FileHandler which falls back to
2127
      the system console if logging fails
2124 2128
  @raise EnvironmentError: if we can't open the log file and
2125 2129
      syslog/stderr logging is disabled
2126 2130

  
......
2172 2176
    # the error if stderr_logging is True, and if false we re-raise the
2173 2177
    # exception since otherwise we could run but without any logs at all
2174 2178
    try:
2175
      logfile_handler = logging.FileHandler(logfile)
2179
      if console_logging:
2180
        logfile_handler = LogFileHandler(logfile)
2181
      else:
2182
        logfile_handler = logging.FileHandler(logfile)
2176 2183
      logfile_handler.setFormatter(formatter)
2177 2184
      if debug:
2178 2185
        logfile_handler.setLevel(logging.DEBUG)

Also available in: Unified diff