pyjld.logger: cross-platform logging utilities
@author: Jean-Lou Dupont
Logger with message look-up and & string.Template functionality
| Parameters: |
|
|---|
The logger must have the following methods:
The :param template_factory: must have a method safe_substitute to render the messages. It defaults to the Template class from the standard string module thus supporting parameters through the escape sequence starting with the $ character eg. $var
Simple usage
>>> import pyjld.logger
>>> messages = ["msg1":"Message1 [$var]"]
>>> ml = pyjld.logger.MsgLogger("app_name", messages)
>>> ml.info('msg1', var="variable1")
... app_name INFO : Message1 [variable1]
Proxy helper
This class is meant to be private to this module.
Returns a simple cross-platform logger
Usage
>>> log = logger.logger('my_logger')
>>> log.info('message')
Cross-platform syslog handler
For Unix/Linux platforms, the filesystem path used is as follows
/var/log/$appname$.log
The standard SysLogHandler from the logging package is more difficult to configure as it defaults to using the port localhost:514.