[Tutor] Logging with proper format

wormwood_3 wormwood_3 at yahoo.com
Sun Oct 7 21:47:04 CEST 2007


Sent this almost an hour ago, did not get it from the list yet. No idea why, but sending again...
--------------------------

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) )

The current output:

2007-10-07 14:49:42,902 - ipinfo - INFO -     Checked 4 records in 0.0698790550232 seconds, yielding an average of             0.0174697637558 seconds per record.

Desired output would be:

2007-10-07 14:49:42,902 - ipinfo - INFO -     Checked 4 records in 0.0698790550232 seconds, yielding an average of 0.0174697637558 seconds per record.

So what is the best way to break long code lines and still preserve desired output?

Thanks,
Sam








More information about the Tutor mailing list