[Twisted-Python] Persuading Python's Logging to use twisted.logger

Burak Arslan burak.arslan at arskom.com.tr
Mon May 9 23:22:18 MDT 2016


hello,

On 05/09/16 23:50, Daniel Sutcliffe wrote:
> The project I am working on uses pymodbus which I am sure shares a
> fairly common attribute with many other modules of using Python's
> standard Logging mechanism - a very reasonable choice even for a
> module that supports Twisted, the library can also be used entirely
> synchronously and thus would not want a required dependency of
> Twisted.
>
> It struck me that it would be great to be able to redirect the
> standard logging library to use twisted.logger

me too :)

> 'Warning: specific logging configurations (example: network)
> can lead to this observer blocking.' which seems to me why it would be
> better to attempt this the other way around...

as discussed, it's possible. you additionally need to make sure to clean
other handlers if you are integrating with third party libraries who may
be adding esoteric targets for log entries behind your back.

with that said, here's my take at it:

https://github.com/plq/neurons/blob/40dff6134330aeadbefd3973d5d40aa4bfac4b78/neurons/daemon/config.py#L673

best,
burak




More information about the Twisted-Python mailing list