[Twisted-Python] stdlib logger, loggerFor and filtering events

Felipe Dau dau at riseup.net
Fri Jan 5 20:11:12 MST 2018


As the logger has been brought up, I'd like to ask a couple things:

1) When I was working on adding logs to an application, I wanted it to
use both the `textFileLogObserver` and the `STDLibLogObserver`. As the
application could be used either with its CLI or GUI, it seemed
interesting to have both these loggers available. I was able to do
that but I wanted them to have the same format - specifically, I
wanted to use the file's format (which is awesome btw) - and had to
override some parts of the `STDLibLogObserver`. It would have made
things a lot simpler if that observer accepted a function to format
events like the `FileLogObserver`.

2) Why is `_loggerFor` "private/hidden"? That is a great factory which
imo should have more visibility - and also works great with attrs!:

     attr.ib(default=attr.Factory(_loggerFor, takes_self=True))

3) Is there a way to suppress logs from libs or any other code that
is not your own? In my case, I had to manually set which namespaces
I wanted to filter but, for example, when you subclass a third-party's
class which logs something, that will pass because now it belongs to
one of your namespaces. I know it sounds crazy but wanted to know what
other people think.

If any of these changes sound like they would be useful apart from the
specific requirements of that application, I could help implement
something based on what I wrote [0].

Thanks,
-Felipe

[0]: https://github.com/AnemoneLabs/unmessage/blob/develop/unmessage/log.py



More information about the Twisted-Python mailing list