Currently the watchdog() function is logging events using REQUEST_TIME constant which is just $_SERVER['REQUEST_TIME']. This works fine in most cases but processes that take an extended period of time all get logged at the time the process began, and not when the event actually happened. For example when running data migration scripts that can take much longer to process all of the errors get logged at the time the process began. It seems that watchdog would be more accurate if it logged the time with time() instead.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Andre-B’s picture

Version: 8.x-dev » 7.x-dev

same for d7, this causes unwanted issues with drupal queue and long running cronjobs. One could also log the REQUEST_TIME in an additional field, but from my point of view timestamp should contain the time the function has been called.

cangeceiro’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
FileSize
589 bytes

attached is a patch for d8

cangeceiro’s picture

FileSize
569 bytes

and a backport to d7

catch’s picture

Status: Needs review » Needs work

Makes sense, but we should add a comment so this doesn't get reverted again later.

cangeceiro’s picture

FileSize
660 bytes

like so?

cangeceiro’s picture

Status: Needs work » Needs review

status change

Status: Needs review » Needs work

The last submitted patch, drupal-1239410-8.x.patch, failed testing.

cangeceiro’s picture

FileSize
660 bytes

reroll of patch.

cangeceiro’s picture

Status: Needs work » Needs review
ramlev’s picture

Status: Needs review » Reviewed & tested by the community

Tested an working.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+      'timestamp'   => time(), // Request time isn't accurate for long processes.  Use time() instead

This comment doesn't confirm to the coding standards, it should be above the line and be a full sentence with a period at the end. See http://drupal.org/coding-standards

swentel’s picture

Status: Needs work » Needs review
FileSize
667 bytes

Move the comment above the line.

Status: Needs review » Needs work

The last submitted patch, 1239410-12.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review

#12: 1239410-12.patch queued for re-testing.

Andre-B’s picture

#12: 1239410-12.patch queued for re-testing.

jbrown’s picture

#12: 1239410-12.patch queued for re-testing.

jbrown’s picture

Category: feature » bug
Status: Needs review » Reviewed & tested by the community
webchick’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs backport to D7

I think this makes sense, as a valid use of time(). Thanks!

Committed and pushed to 8.x. Probably makes sense to backport to 7.x, too.

jbrown’s picture

Status: Patch (to be ported) » Needs review
FileSize
731 bytes
jbrown’s picture

Status: Needs review » Reviewed & tested by the community

Same patch as D8.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.