Share and Money Management  0.16
Classes | Functions | Variables
gui.log Namespace Reference

This module provides a own logger class as well as specific funtions to improve Pythons logging facility. More...

Classes

class  StringHandler
 Stores the log records as a list of strings. More...
class  StreamHandler
class  FileHandler

Functions

def init
 Initialise the logging facility.
def deinit
 Reactivate system exception handler.
def getBufferAsList
 Returns all buffered messages.
def getBufferAsString
 Returns all buffered messages.
def flush
 Empty the buffer.
def exception
 Logs an exception message and the formatted traceback.
def installExceptionHandler
 Install own exception handler.
def deinstallExceptionHandler
 Restore the original exception handler.
def exceptionHandler
 Logs detailed information about uncatched exceptions.
def getMessage
 Return the message for this LogRecord.

Variables

 stringLoggerInstance = None
 Reference to the active StringHandler instance.
 _orig_exec_handler = None
 Contains the original exception handler.

Detailed Description

This module provides a own logger class as well as specific funtions to improve Pythons logging facility.

The SMM GUI uses the python logging instance with three log handler attached.

The first handler (StringHandler) is used to cache messages later displaying calling getBufferAsList() or getBufferAsString().

The second handler (StreamHandler) to print error messages to sys.stderr.

The third handler (FileHandler) writes all messages into a file. This behaviour is useful to store logged expections permanently.

Note
The classes StreamHandler and FileHandler are copiied from the current revision (81919 - 27.12.2010) of Python's public SVN repository. Because the implementations included in Python 2.5 and some versions of Python 2.6 aren't ready to handle Unicode properly.
Author
Carsten Grohmann <mail (at) carstengrohmann (dot) de>
License:
GPL version 2.0

Function Documentation

def gui.log.deinit ( )

Reactivate system exception handler.

See Also
deinstallExceptionHandler()

References gui.log.deinstallExceptionHandler().

Here is the call graph for this function:

def gui.log.deinstallExceptionHandler ( )

Restore the original exception handler.

The original exception handler has been saved in _orig_exec_handler.

See Also
_orig_exec_handler and installExceptionHandler()

Referenced by gui.log.deinit().

Here is the caller graph for this function:

def gui.log.exception (   msg,
  args 
)

Logs an exception message and the formatted traceback.

See Also
exceptionHandler()

References gui.log.exceptionHandler().

Here is the call graph for this function:

def gui.log.exceptionHandler (   exc_type,
  exc_value,
  exc_tb 
)

Logs detailed information about uncatched exceptions.

Parameters
exc_typeType of the exception (normally a class object)
exc_valueThe "value" of the exception
exc_tbCall stack of the exception

Referenced by gui.log.exception().

Here is the caller graph for this function:

def gui.log.flush ( )

Empty the buffer.

def gui.log.getBufferAsList (   clean = True)

Returns all buffered messages.

Parameters
cleanClean the internal message buffer
Returns
List of messages strings
See Also
getBufferAsString()

def gui.log.getBufferAsString (   clean = True)

Returns all buffered messages.

Parameters
cleanClean the internal message buffer
Returns
Messages concatenate to a string
See Also
getBufferAsList(self,)

def gui.log.getMessage (   self)

Return the message for this LogRecord.

Return the message for this LogRecord after merging any user-supplied arguments with the message.

This SMM specific version tries to handle Unicode user-supplied arguments.

def gui.log.init (   filename = 'smm.log',
  encoding = None,
  level = None 
)

Initialise the logging facility.

Initialise and configure the logging itself as well as the handlers described above.

Our own execption handler will be installed finally.

Parameters
filenameName of the log file
encodingEncoding of the log file
levelVerbosity of messages written in log file
See Also
StringHandler, stringLoggerInstance and installExceptionHandler()

References gui.log.installExceptionHandler().

Here is the call graph for this function:

def gui.log.installExceptionHandler ( )

Install own exception handler.

The original exception handler is saved in _orig_exec_handler.

See Also
_orig_exec_handler and deinstallExceptionHandler()

Referenced by gui.log.init().

Here is the caller graph for this function:

Variable Documentation

gui.log._orig_exec_handler = None

Contains the original exception handler.

See Also
installExceptionHandler() and deinstallExceptionHandler()
gui.log.stringLoggerInstance = None

Reference to the active StringHandler instance.