Anyone who's worked with Drupal a while knows how frustrating it can be trying to debug problems with cron.
The problem is, there's no way of knowing which module is running cron, how long it runs for and at which point cron is failing across all the available hook_cron implementations.
The attached patches provide a "debug mode" checkbox on the admin cron settings form which records detailed timing information about cron runs for each module, to the watchdog - when enabled.
I've been successfully using this patch for a while now to debug cron and have found it very helpful, as have many others on irc. and would like to commit it to benefit others.
Please review, provide any feedback and commit if possible.
cheers,
David
P.S Drupal rocks!
Comment | File | Size | Author |
---|---|---|---|
#6 | 1143082-cron_timer.patch | 3.55 KB | brianV |
#2 | cron-settings-checkbox.png | 23.49 KB | davidwhthomas |
#2 | sample-watchdog-cron-log.png | 147.01 KB | davidwhthomas |
#1 | cron-log-information.png | 165.4 KB | davidwhthomas |
enable-cron-debug-mode.patch | 2.19 KB | davidwhthomas | |
Comments
Comment #1
davidwhthomas CreditAttribution: davidwhthomas commentedThe attached screenshot shows sample logging information under recent log entries for cron.
Comment #2
davidwhthomas CreditAttribution: davidwhthomas commentedMore up-to-date screenshots
Comment #3
tstoecklerReposting from the other issue:
If this can be done from contrib, I think it would be a useful feature for the Devel module.
Comment #4
davidwhthomas CreditAttribution: davidwhthomas commentedThanks for the suggestion.
Although it would be convenient for regular users to be able to switch this debug mode on / off in core, looking at putting it into devel as a contrib module or patch is a reasonable approach too.
I will look into this and follow it up with the Devel maintainers.
Comment #5
davidwhthomas CreditAttribution: davidwhthomas commentedNote, I'm still interested in getting this into core, if there's interest from others..
Comment #6
brianV CreditAttribution: brianV commentedI really like this idea, and have rolled a D8 patch to implement it.
That said, I don't necessarily agree that we should call it a 'debug mode'. I believe referring to it as a timer is more precise. It's also useful for more than simply debugging.
I've also rounded the time to four positions rather than two, as for very short operations, the timer often shows 0 seconds.
Comment #7
brianV CreditAttribution: brianV commentedRe-titling
Comment #9
brianV CreditAttribution: brianV commented#6: 1143082-cron_timer.patch queued for re-testing.
Comment #11
brianV CreditAttribution: brianV commented#6: 1143082-cron_timer.patch queued for re-testing.
Comment #13
brianV CreditAttribution: brianV commented#6: 1143082-cron_timer.patch queued for re-testing.
Comment #14
brianV CreditAttribution: brianV commentedFifth time is the charm - no random testbot implosions...
Comment #19
Dane Powell CreditAttribution: Dane Powell at Acquia commentedThe functionality and patch in this thread have basically been implemented already in #2716073: Improve cron logging and #2823543: Make cron execution logging optional