log
index
/home/aki/wrk/git-mozharness-ro/mozharness/base/log.py

Generic logging, the way I remember it from scripts gone by.
 
TODO:
- network logging support.
- log rotation config

 
Modules
       
logging
os
sys
traceback

 
Classes
       
__builtin__.object
BaseLogger
MultiFileLogger
SimpleFileLogger
LogMixin
OutputParser

 
class BaseLogger(__builtin__.object)
    Create a base logging class.
TODO: status? There may be a status object or status capability in
either logging or config that allows you to count the number of
error,critical,fatal messages for us to count up at the end (aiming
for 0).
 
  Methods defined here:
__del__(self)
__init__(self, log_level='info', log_format='%(message)s', log_date_format='%H:%M:%S', log_name='test', log_to_console=True, log_dir='.', log_to_raw=False, logger_name='', halt_on_failure=True, append_to_log=False)
add_console_handler(self, log_level=None, log_format=None, date_format=None)
add_file_handler(self, log_path, log_level=None, log_format=None, date_format=None)
create_log_dir(self)
get_log_formatter(self, log_format=None, date_format=None)
get_logger_level(self, level=None)
init_message(self, name=None)
log_message(self, message, level='info', exit_code=-1)
Generic log method.
        There should be more options here -- do or don't split by line,
        use os.linesep instead of assuming 
, be able to pass in log level
        by name or number.
 
        Adding the IGNORE special level for runCommand.
new_logger(self, logger_name)
Create a new logger.
By default there are no handlers.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
LEVELS = {'critical': 50, 'debug': 10, 'error': 40, 'fatal': 60, 'info': 20, 'warning': 30}

 
class LogMixin(__builtin__.object)
    This is a mixin for any object to access similar logging
functionality -- more so, of course, for those objects with
self.config and self.log_obj, of course.
 
  Methods defined here:
critical(self, message)
debug(self, message)
error(self, message)
exception(self, message=None, level='error')
# Copying Bear's dumpException():
http://hg.mozilla.org/build/tools/annotate/1485f23c38e0/sut_tools/sut_lib.py#l23
fatal(self, message, exit_code=-1)
info(self, message)
log(self, message, level='info', exit_code=-1)
warning(self, message)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class MultiFileLogger(BaseLogger)
    Create a log per log level in log_dir.  Possibly also output to
the terminal and a raw log (no prepending of level or date)
 
 
Method resolution order:
MultiFileLogger
BaseLogger
__builtin__.object

Methods defined here:
__init__(self, logger_name='Multi', log_format='%(asctime)s %(levelname)8s - %(message)s', log_dir='logs', log_to_raw=True, **kwargs)
new_logger(self, logger_name)

Methods inherited from BaseLogger:
__del__(self)
add_console_handler(self, log_level=None, log_format=None, date_format=None)
add_file_handler(self, log_path, log_level=None, log_format=None, date_format=None)
create_log_dir(self)
get_log_formatter(self, log_format=None, date_format=None)
get_logger_level(self, level=None)
init_message(self, name=None)
log_message(self, message, level='info', exit_code=-1)
Generic log method.
        There should be more options here -- do or don't split by line,
        use os.linesep instead of assuming 
, be able to pass in log level
        by name or number.
 
        Adding the IGNORE special level for runCommand.

Data descriptors inherited from BaseLogger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from BaseLogger:
LEVELS = {'critical': 50, 'debug': 10, 'error': 40, 'fatal': 60, 'info': 20, 'warning': 30}

 
class OutputParser(LogMixin)
    Helper object to parse command output.
 
This will buffer output if needed, so we can go back and mark
[(linenum - 10):linenum+10] as errors if need be, without having to
get all the output first.
 
linenum+10 will be easy; we can set self.num_post_context_lines to 10,
and self.num_post_context_lines-- as we mark each line to at least error
level X.
 
linenum-10 will be trickier. We'll not only need to save the line
itself, but also the level that we've set for that line previously,
whether by matching on that line, or by a previous line's context.
We should only log that line if all output has ended (finish() ?);
otherwise store a list of dictionaries in self.context_buffer that is
buffered up to self.num_pre_context_lines (set to the largest
pre-context-line setting in error_list.)
 
 
Method resolution order:
OutputParser
LogMixin
__builtin__.object

Methods defined here:
__init__(self, config=None, log_obj=None, error_list=None, log_output=True)
add_lines(self, output)
parse_single_line(self, line)
worst_level(self, target_level, existing_level, levels=None)
returns either existing_level or target level.
This depends on which is closest to levels[0]
By default, levels is the list of log levels

Methods inherited from LogMixin:
critical(self, message)
debug(self, message)
error(self, message)
exception(self, message=None, level='error')
# Copying Bear's dumpException():
http://hg.mozilla.org/build/tools/annotate/1485f23c38e0/sut_tools/sut_lib.py#l23
fatal(self, message, exit_code=-1)
info(self, message)
log(self, message, level='info', exit_code=-1)
warning(self, message)

Data descriptors inherited from LogMixin:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class SimpleFileLogger(BaseLogger)
    Create one logFile.  Possibly also output to
the terminal and a raw log (no prepending of level or date)
 
 
Method resolution order:
SimpleFileLogger
BaseLogger
__builtin__.object

Methods defined here:
__init__(self, log_format='%(asctime)s %(levelname)8s - %(message)s', logger_name='Simple', log_dir='logs', **kwargs)
new_logger(self, logger_name)

Methods inherited from BaseLogger:
__del__(self)
add_console_handler(self, log_level=None, log_format=None, date_format=None)
add_file_handler(self, log_path, log_level=None, log_format=None, date_format=None)
create_log_dir(self)
get_log_formatter(self, log_format=None, date_format=None)
get_logger_level(self, level=None)
init_message(self, name=None)
log_message(self, message, level='info', exit_code=-1)
Generic log method.
        There should be more options here -- do or don't split by line,
        use os.linesep instead of assuming 
, be able to pass in log level
        by name or number.
 
        Adding the IGNORE special level for runCommand.

Data descriptors inherited from BaseLogger:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from BaseLogger:
LEVELS = {'critical': 50, 'debug': 10, 'error': 40, 'fatal': 60, 'info': 20, 'warning': 30}

 
Data
        CRITICAL = 'critical'
DEBUG = 'debug'
ERROR = 'error'
FATAL = 'fatal'
FATAL_LEVEL = 60
IGNORE = 'ignore'
INFO = 'info'
WARNING = 'warning'