logging module -- better timestamp accuracy on Windows

benhoyt benhoyt at gmail.com
Wed Feb 16 09:30:52 EST 2011


> A simpler solution would be to caclulate the time it takes to the handle
> the request using time.clock() and include it in the log message.
> Something like:

Thanks, Ross. Actually, we are doing exactly that already -- it's how we noticed the timestamp issue in the first place. However, that doesn't fix it when we have multiple logged events that we want to calculate time deltas between, such as:

2011-02-15T10:11:12.123 Starting request
2011-02-15T10:11:12.123 Doing stuff
2011-02-15T10:11:12.123 Filtering stuff
2011-02-15T10:11:12.123 Rendering template
2011-02-15T10:11:12.123 Request complete, took 0.56 ms

It seems to me that the logging module should use a millisecond-accurate timestamp (time.clock) on Windows, just like the "timeit" module does.

-Ben



More information about the Python-list mailing list