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

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

Classes

class  ExceptionFormatter
 Extended formatter to include more exception details automatically. More...
 
class  StringHandler
 Stores the log records as a list of strings. More...
 

Functions

def init (filename="smm.log", encoding="utf-8", level=None)
 Initialise the logging facility. More...
 
def deinit ()
 Reactivate system exception handler. More...
 
def getBufferAsList (clean=True)
 Returns all buffered messages. More...
 
def getBufferAsString (clean=True)
 Returns all buffered messages. More...
 
def flush ()
 Empty the buffer. More...
 
def installExceptionHandler ()
 Install own exception handler. More...
 
def deinstallExceptionHandler ()
 Restore the original exception handler from sys.__excepthook__. More...
 
def exceptionHandler (exc_type, exc_value, exc_tb)
 Logs detailed information about uncaught exceptions. More...
 
def getMessage (self)
 Return the message for this LogRecord. More...
 

Variables

 stringLoggerInstance = None
 Reference to the active StringHandler instance. More...
 

Detailed Description

This module provides an own logger class as well as specific functions 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 (RotatingFileHandler) writes all messages into a file. This behaviour is useful to store logged exceptions permanently.

Author
Carsten Grohmann <mail (at) carstengrohmann (dot) de>
License:
GPL version 2.0

Function Documentation

◆ deinit()

def gui.log.deinit ( )

Reactivate system exception handler.

See also
deinstallExceptionHandler()

References gui.log.deinstallExceptionHandler().

Here is the call graph for this function:

◆ deinstallExceptionHandler()

def gui.log.deinstallExceptionHandler ( )

Restore the original exception handler from sys.__excepthook__.

See also
installExceptionHandler()

Referenced by gui.log.deinit().

Here is the caller graph for this function:

◆ exceptionHandler()

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

Logs detailed information about uncaught exceptions.

The exception information will be cleared after that.

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

◆ flush()

def gui.log.flush ( )

Empty the buffer.

See also
stringLoggerInstance

Referenced by tests.test_objects.TestObjects.test_Position_objects().

Here is the caller graph for this function:

◆ getBufferAsList()

def gui.log.getBufferAsList (   clean = True)

Returns all buffered messages.

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

◆ 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()
stringLoggerInstance

◆ getMessage()

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.

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

◆ init()

def gui.log.init (   filename = "smm.log",
  encoding = "utf-8",
  level = None 
)

Initialise the logging facility.

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

Our own exception handler will be installed finally.

The file logger won't be instantiated if not file name is given.

Parameters
filenameName of the log file
encodingEncoding of the log file
levelVerbosity of messages written in log file e.g. "INFO"
See also
StringHandler
stringLoggerInstance
installExceptionHandler()

References gui.log.installExceptionHandler().

Here is the call graph for this function:

◆ installExceptionHandler()

def gui.log.installExceptionHandler ( )

Install own exception handler.

See also
deinstallExceptionHandler()

Referenced by gui.log.init().

Here is the caller graph for this function:

Variable Documentation

◆ stringLoggerInstance

gui.log.stringLoggerInstance = None

Reference to the active StringHandler instance.