[Twisted-Python] Use python logging module with Twisted log

G'day,
I've created an xmlrpc server with twisted and was wondering if it would be possible to use twisted logging and the python logging module together. This because the xmlrpc server uses a 'back-end' that contains python modules that are also used by other processes/servers.
It should be possible if a twisted handler for the python logging module existed ... it would then be a case of attaching the twisted handler to the logger and the connection would be established.
Before I take on this task myself, I wonder if someone else has created such a handler or maybe has some other/better way of interconnecting to the python logging module?
BTW .. where can I find some (detailed) documentation on the twisted logging system use?
Regards, Remi Cool

On Mon, 2005-08-29 at 16:29 +0200, Remi Cool wrote:
BTW .. where can I find some (detailed) documentation on the twisted logging system use?
There isn't any, and really it needs some work. However, the basics are, you write a callable that accepts a dictionary, and then:
twisted.python.log.addObserver(yourCallable)
The dictionary you get depends on whether it's log.msg or log.err. You can then do what you want with it.
Important notes: 1. Never raise an exception from a log observer. It will be removed.
2. Never block in a log observer, as it may run in main Twisted thread. This means you can't use socket or syslog Python-logging backends.
3. The observer needs to be thread safe if you anticipate using threads in your program.
participants (2)
-
Itamar Shtull-Trauring
-
Remi Cool