module documentation

Utility functions for logging.

Function SetupLogging Configures the logging module.
Function SetupToolLogging Configures the logging module for tools.
Class _ReopenableLogHandler Log handler with ability to reopen log file on request.
Function _GetLogFormatter Build log formatter.
Function _LogErrorsToConsole Create wrapper class writing errors to console.
Function _ReopenLogFiles Wrapper for reopening all log handler's files in a sequence.
Variable _LogHandler Undocumented
def SetupLogging(logfile, program, debug=0, stderr_logging=False, multithreaded=False, syslog=constants.SYSLOG_USAGE, console_logging=False, root_logger=None):

Configures the logging module.

Parameters
logfile:strthe filename to which we should log
program:strthe name under which we should log messages
debug:integerif greater than zero, enable debug messages, otherwise only those at INFO and above level
stderr_logging:booleanwhether we should also log to the standard error
multithreaded:booleanif True, will add the thread name to the log file
syslog:string

one of 'no', 'yes', 'only':

  • if no, syslog is not used
  • if yes, syslog is used (in addition to file-logging)
  • if only, only syslog is used
console_logging:booleanif True, will use a FileHandler which falls back to the system console if logging fails
root_logger:logging.LoggerRoot logger to use (for unittests)
Returns
callableFunction reopening all open log files when called
Raises
EnvironmentErrorif we can't open the log file and syslog/stderr logging is disabled
def SetupToolLogging(debug, verbose, threadname=False, _root_logger=None, _stream=None):

Configures the logging module for tools.

All log messages are sent to stderr.

Parameters
debug:booleanDisable log message filtering
verbose:booleanEnable verbose log messages
threadname:booleanWhether to include thread name in output
_root_loggerUndocumented
_streamUndocumented
def _GetLogFormatter(program, multithreaded, debug, syslog):

Build log formatter.

Parameters
programProgram name
multithreadedWhether to add thread name to log messages
debugWhether to enable debug messages
syslogWhether the formatter will be used for syslog
def _LogErrorsToConsole(base):

Create wrapper class writing errors to console.

This needs to be in a function for unittesting.

def _ReopenLogFiles(handlers):

Wrapper for reopening all log handler's files in a sequence.

_LogHandler =

Undocumented