Package configshell :: Module log :: Class Log
[hide private]
[frames] | no frames]

Class Log

object --+
         |
        Log

Implements a file and console logger using python's logging facility. Log levels are, in raising criticality:

It uses configshell's Prefs() backend for storing some of its parameters, who can then be read/changed by other objects using Prefs()

Instance Methods [hide private]
 
__init__(self, console_level=None, logfile=None, file_level=None)
This class implements the Borg pattern.
 
_append(self, msg, level)
Just appends the message to the logfile if it exists, prefixing it with the current time and level.
 
_log(self, level, msg)
Do the actual logging.
 
debug(self, msg)
Logs a debug message.
 
exception(self, msg=None)
Logs an error message and dumps a full stack trace.
 
verbose(self, msg)
Logs a verbose message.
 
info(self, msg)
Logs an info message.
 
warning(self, msg)
Logs a warning message.
 
error(self, msg)
Logs an error message.
 
critical(self, msg)
Logs a critical message.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __borg_state = {}
  levels = ['critical', 'error', 'warning', 'info', 'verbose', '...
  colors = {'critical': 'red', 'error': 'red', 'warning': 'yello...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, console_level=None, logfile=None, file_level=None)
(Constructor)

 

This class implements the Borg pattern.

Parameters:
  • console_level (str) - Console log level, defaults to 'info'
  • logfile (str) - Optional logfile.
  • file_level (str) - File log level, defaults to 'debug'.
Overrides: object.__init__

_append(self, msg, level)

 

Just appends the message to the logfile if it exists, prefixing it with the current time and level.

Parameters:
  • msg (str) - The message to log
  • level (str) - The debug level to prefix the message with.

_log(self, level, msg)

 

Do the actual logging.

Parameters:
  • level (str) - The log level of the message.
  • msg (str) - The message to log.

debug(self, msg)

 

Logs a debug message.

Parameters:
  • msg (str) - The message to log.

exception(self, msg=None)

 

Logs an error message and dumps a full stack trace.

Parameters:
  • msg (str) - The message to log.

verbose(self, msg)

 

Logs a verbose message.

Parameters:
  • msg (str) - The message to log.

info(self, msg)

 

Logs an info message.

Parameters:
  • msg (str) - The message to log.

warning(self, msg)

 

Logs a warning message.

Parameters:
  • msg (str) - The message to log.

error(self, msg)

 

Logs an error message.

Parameters:
  • msg (str) - The message to log.

critical(self, msg)

 

Logs a critical message.

Parameters:
  • msg (str) - The message to log.

Class Variable Details [hide private]

levels

Value:
['critical', 'error', 'warning', 'info', 'verbose', 'debug']

colors

Value:
{'critical': 'red', 'error': 'red', 'warning': 'yellow', 'info': 'gree\
n', 'verbose': 'blue', 'debug': 'blue'}