[Tutor] Logging with proper format

Kent Johnson kent37 at tds.net
Sun Oct 7 22:20:26 CEST 2007


wormwood_3 wrote:
> Hello tutors,
> 
> I am adding logging to a program I am writing. I have some messages I want to log that are rather long. The problem I am running into is that when the line is more than the 80 character line recommendation and I split it across 2 lines with "\", the output is affected. 
> 
> Example code:
> 
>         logger.info("Checked %s records in %s seconds, yielding an average of \
>             %s seconds per record." % (len(self.data), duration, avgquery) )

   ^^^^^^^^^^^^ <- this is white space in your string!

Try this:

         logger.info("Checked %s records in %s seconds, yielding an \
average of \
%s seconds per record." % (len(self.data), duration, avgquery) )

Kent


More information about the Tutor mailing list