[Twisted-Python] Need for multiple loggers...

Moof moof at metamoof.net
Sat Jun 10 09:16:40 MDT 2006


On 6/10/06, Chaz. <eprparadocs at gmail.com> wrote:
> I have an application that I am converting to Twisted. One of the things
> the application does is have three different logs running. Each of the
> three does something different.
>
> In normal python logging I figured out how to have the three different
> loggers. In Twisted I am not quite sure how to do it. Has someone done
> this before?

You want to write a class or function that will receive a dictionary
with 'system', 'message', and possibly 'failure', 'isError', 'debug'
and 'printed', and take appropriate action. You may wish to have a
look at twisted.python.log.FileLogObserver. Once you have the function
or method, you can do a log.addLogObserver(function).

You can pass things on to the eventDict as keywords to log.msg,
log.error, and log.debug (though the last one is deprecated). If you
find that isn't enough for you, it's possible to replace the
LogPublisher with something that can gather more data, I currently use
one that inspects the stack for which module called it, for example.

Moof




More information about the Twisted-Python mailing list