Package buildxml :: Package xmlgetter :: Module log :: Class BaseLogger
[hide private]
[frames] | no frames]

Class BaseLogger

source code

This is the base class for all classes that want to use the logging system. The class has only one public property logger, which returns a logging.Logger instance. The filename of the log is defined in config.LOG_FILENAME, the logging level in config.LOG_LEVEL and the rollover size of the logfile in config.LOG_ROLLOVER_SIZE.

Instance Methods [hide private]
 
__init__(self, source_name=None)
Initialize the BaseLogger.
source code
logging.Logger
logger(self)
Returns a logging.Logger instance.
source code
logging.Logger
_getLogger(self, logger_name)
Creates a logging.Logger instance with the logging parameters taken from config.
source code
Class Variables [hide private]
dict _loggers = {}
Stores all instances of logging.Logger that are created by the property function logger with their name as key.
Instance Variables [hide private]
string _source_name = None
The value of this variable will be used in the loggers names.
Method Details [hide private]

__init__(self, source_name=None)
(Constructor)

source code 

Initialize the BaseLogger.

Parameters:

logger(self)

source code 

Returns a logging.Logger instance.

If the is an instance variable _source_name, use the classname and self._source_name as logger name, otherwise use only the classname.

The Logger instances will be stored in the _loggers dictionary by their name. A new instance will only be created if no logger with that name already exists in the dictionary.

Returns: logging.Logger
A Logger that logs to LOG_FILENAME .
Decorators:
  • @property

_getLogger(self, logger_name)

source code 

Creates a logging.Logger instance with the logging parameters taken from config. The LOG_LEVEL specifies which messages get logged to LOG_FILENAME. If LOG_ROLLOVER_SIZE is > 0, then LOG_BACKUP_COUNT copies of old logfiles with size LOG_ROLLOVER_SIZE will be kept.

Returns: logging.Logger
The newly created logger.