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

Henning.Ramm at mediapro-gmbh.de Henning.Ramm at mediapro-gmbh.de
Mon Aug 29 16:37:43 EDT 2005


>The dictionary you get depends on whether it's log.msg or log.err. You
>can then do what you want with it.

A little bit of information, what keys can occurr and what they mean would be nice.

How about this (if self.log is a logging.Logger);
code is partly stolen from twisted.python.log:

    def twisted_logger(self, logdict):
        """
        log observer for twisted.python.log, receives a dict and writes to self.log
        """
        if 'failure' in logdict:
            text = logdict['failure'].getTraceback()
        else:
            text = " ".join([str(m) for m in logdict["message"]])
        if logdict['isError']:
            self.log.error(text)
        else:
            self.log.warning(text)


Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.




More information about the Twisted-Python mailing list