[Python-projects] Checker for use of the standard logging module

Maarten ter Huurne maarten at treewalker.org
Thu Jun 11 02:31:04 CEST 2009


On Thursday 11 June 2009, Nathaniel Manista wrote:

>     Adds a checker for logging methods to pylint, flagging methods of the
> form "logging.<method>(format_string % <format_args>)". Such methods
> should be written as "logging.<method>(format_string, format_args)" with
> the interpolation left to the logging method.

I was going to ask what the advantage is to letting the logging method do 
the formatting, but then I did some research and found an explanation in PEP 
282: the logger can test first whether this message should or should not be 
logged (by testing log level etc) and then skip expensive string formatting 
if the message will not be logged.

http://www.python.org/dev/peps/pep-0282/

Other people might also have this question as well, so maybe the motivation 
for this rule can be added to the documentation?
(I don't have Mercurial installed, so I did not look at the patch, maybe 
it's already there)

Bye,
		Maarten



More information about the Python-Projects mailing list