[Twisted-Python] Use python logging module with Twisted log
Itamar Shtull-Trauring
itamar at itamarst.org
Mon Aug 29 16:13:30 EDT 2005
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.
More information about the Twisted-Python
mailing list