any use case of logging.config.listen()?

Zhang Weiwu tristan at realss.com
Wed Dec 4 04:09:22 EST 2013


Thank you a lot for your case description.

On Wed, 4 Dec 2013, Dan Sommers wrote:

>> It begets the question, that if it is easier to write a
>> socket-listening loging handler and forget all about
>> logging.config.listen() stuff. I never did it before, hence the
>> question.
>
> But why develop all of that code when logging.config.listen() already
> exists?  Adding a new SocketHandler seems more heavyweight (and more
> risky) than adjusting the logging level on an existing SocketHandler.

There are 2 reasons that i cannot just use existing API for the project I am 
working on.

1. My monitoring GUI client is often behind various NAT. In fact it is a 
hand-held client, I could be using it in a café's WIFI. It is impossible to 
tell the python-daemon to just send the log to given address and port.

2. I forgot to explain that in my project adjusting log level is only half 
of what needs to be done. The monitoring GUI client also needs to be able to 
send a few operational parameters' change. e.g. I need to see the log, and 
decide to change 'Threshold' from 0.5 to 0.53 and see the difference.

For the first problem, a new logging.ListeningSocketHandler would work - 
don't know if it is easy to write one - which can be written in a way that 
simply drops logs if no one is listening, thus forgoing logging.config.listen().

For the second problem, a way to dynamically accept new operational 
paramters from socket is needed, solo logging.config.listen() wouldn't 
suffice.

Either case I don't find use of logging.config.listen(), even though I am 
looking hard for every way to reuse existing code.


More information about the Python-list mailing list