Skip to main content

Posts

Showing posts from July, 2010

Custom logging handler in Turbogears

Configure a custom logging handler(such as subclass of logging.Handler) may induce errors. We could add custom logging handler in controllers.py. Considering a prod.cfg or dev.cfg as below: [logging] ... [[[allinfo]]] level='INFO' handlers=['debug_out'] [[[access]]] level='INFO' qualname='turbogears.access' handlers=['access_out'] propagate=0 We could add FileHandler for allinfo by: logging.getLogger().addHandler(logging.FileHandler('allinfo.log','a') ) and for access: logging.getLogger("turbogears.access").addHandler(logging.FileHandler('access.log','a') ) In prod.cfg, we could direct the default logging output to NullHandler or simply left blank.

Scribe client/proxy in Python

I have tested two Python scribe client/proxy, python-scribe-logger and ScribeHandler . python-scribe-logger has a Writer and a Logger , where the Writer handles the writing to scribe server and the Logger provide a handler for python logging module. The Writer in python-scribe-logger uses a threading.RLock to ensure the access of TTransport. LoggerScribeHandler is much simpler. It only implements an handler for python logging module, and no locking. Maybe better for single thread uses.