[Twisted-Python] Getting started on making the move to the new logging system

Glyph Lefkowitz glyph at twistedmatrix.com
Mon Apr 27 14:29:42 MDT 2015


> On Apr 27, 2015, at 10:57 AM, Eeshan Garg <jerryguitarist at gmail.com> wrote:
> 
> Hi everyone!
> 
> I have gone through <http://twisted.readthedocs.org/en/latest/core/howto/logging.html <http://twisted.readthedocs.org/en/latest/core/howto/logging.html>> and <http://twisted.readthedocs.org/en/latest/core/howto/logger.html <http://twisted.readthedocs.org/en/latest/core/howto/logger.html>>. And I want to get started helping out with making the move to the new logging system.
> 
> I talked to Glyph and ralphm about this at the PyCon sprints. The main purpose of this email is that I would like some advice as to how to move forward. Are there any other docs that I should read? Also, where should I start? What should be the scope of each individual ticket? 

My initial suggestion - don't take this too authoritatively, I'd be happy for input from anyone else - would be that the next step would be to simply identify a module that has some interesting log events, make a ticket for logging them using the new system, and then write a patch for that ticket.

The scope of each ticket should be as small as possible, given that small tickets get through review faster.  Keep in mind though that there is probably insufficient test coverage for log statements as it is, so you'll almost certainly have to add tests which assert things about the new messages even if the logging statements themselves were covered by HTTP/1.1.

One good place to start would either be in twisted.web, or in some of the "core" logging messages we see all of the time, like twisted.internet.protocol.Factory.doStart.  Right now the only way to control that particular message is to set the 'noisy' attribute on Factory, but the new logging system has an explicit filtering step which can start to provide better support for controlling chatty subsystems.

Another thing to keep an eye on as you do this is to make sure that you convert any string-formatting you find in log messages - like, for example, the '"Starting factory %r" % self' in the message I referenced - and replace it with structured formatting, like self.logger.info("Starting factory {self}").

> I was talking to adiroiban and hawkowl on IRC about this, and they also recommended that I send an email to the mailing list before getting started, so here I am. I would really appreciate it if you could give me some advice and guidance regarding this. :-)

Sounds like good advice.

Good luck, and feel free to keep asking questions,

-glyph

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20150427/2c2e3683/attachment-0002.html>


More information about the Twisted-Python mailing list