Bug ID: 62713
           Summary: wfDebugLog timestamp should show fraction of second
           Product: MediaWiki
           Version: 1.23-git
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: minor
          Priority: Unprioritized
         Component: Logging
       Web browser: ---
   Mobile Platform: ---

Created attachment 14830
Patch file for wfDebugLog to render more precise timestamps

Log entries from wfDebugLog() include a timestamp that shows the time to the
nearest second. It is often the case that many actions complete and many log
items are output in a single second, all showing the same timestamp.
Consequently, often the timestamp is not precise enough to properly evaluate
timing between events, especially those events that occur within the same
timestamp second.

This is different from the wfDebug() function, which renders timestamps to the
nearest 0.0001 second when the $wgDebugTimestamps global is set. Note that Bug
14601 recommends using wfDebugLog() instead of the more widely used wfDebug().

PHP provides a microtime() function that reports time with the fractional part
of the second, but the current wfDebugLog code relies on the MWDateTime()
object, which does not store (or render) time more precisely than one second.

The attached patch demonstrates one possible solution using microtime() to
fetch the timestamp with the fractional second part, and appending that
fractional part to the timestamp in the log entry.

The patch only produces this more precise when the global variable
$wgDebugLogTimestampPrecision is set to a number that represents the digits of
precision greater than zero. The actual number of digits would not exceed the
total number of digits provided by microtime(). If this global is zero (0) or
is not set, the behavior is exactly as without the patch. For example:

 // show timestamps to the nearest millisecond
 $wgDebugLogTimestampPrecision = 3;

As with the current wfDebugLog timestamp, the more precise timestamp provided
by this example patch includes the decimal fraction of a second in a manner
that is compatible with ISO 8601 (without the date/time "T" separator):
"YY-MM-DD HH:MM:SS.S[...]". The time zone is omitted, as before.

Another solution that might apply much more broadly would include modifying the
MWDateTime object to record and render time more precisely.

You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
Wikibugs-l mailing list

Reply via email to