There was interest in having the same functionality that is now in Drupal 6: watchdog hook to enable customized logging and alerts via modules.
Here is a patch for this, tested against 5.1.
Some notes:
1. The patch has the dblog.module and syslog.module in it.
2. If you install this against an pristine tar ball that has yet to be installed, it should work seamlessly, with no warnings. However, if you install it on a site that has already been installed, you will get a warning about the watchdog table already being there. It is safe to ignore this warning. You also don't need to worry about this if you will NOT be using the dblog module.
3. If you decide to use the dblog module, you need to run update.php so that the severity level will be correct for the old entries in the watchdog table. It remains to be seen what will happen when you upgrade to Drupal 6.x, because it will try to once again change the severity codes. Since the watchdog entries are transient in nature, it is safe to just delete rows prior to the upgrade.
To core committers: I do not expect this to go in the 5.x branch, rather it is here for anyone to apply locally to their Drupal 5.x installation if they want. So, no need to bother yourself with it.
Comment | File | Size | Author |
---|---|---|---|
#24 | watchdog-hook-5.21-may_cache.patch | 37.72 KB | sillygwailo |
#22 | watchdog-hook-5.20-may_cache.patch | 37.72 KB | John Morahan |
#21 | watchdog-hook-5.20-litwol-cvs.patch | 37.65 KB | John Morahan |
#20 | watchdog-hook-5.20-litwol.patch | 37.79 KB | John Morahan |
#19 | watchdog-hook-5.20.patch | 39.81 KB | sillygwailo |
Comments
Comment #1
drummCorrect, this will not go into 5.x.
Comment #2
sillygwailodblog.module might need a slight modification. I periodically get the following error:
Fatal error: Call to undefined function: arg() in /var/www/DRUPAL-5/html/modules/dblog/dblog.module on line 98
The change at https://svn.bryght.com/dev/changeset/799 and I attached a patch generated by 'svn diff' between the revisions. Credit goes to Steven, who explained to me that hook_init doesn't work quite the same way in Drupal 5 as it does in Drupal 6, and that arg() isn't available to dblog_init() in the Drupal 5 version. The way to get around it is to use hook_menu.
Comment #3
sillygwailoPatch was malformed. Trying again.
Comment #4
John Morahan CreditAttribution: John Morahan commentedI couldn't get Richard's patch to apply, but I made the change he described (using hook_menu instead of hook_init) and rerolled the whole thing against 5.2
Comment #5
Hetta CreditAttribution: Hetta commentedxx (wrong project, sorry)
Comment #6
Hetta CreditAttribution: Hetta commented(xx)
Comment #7
sillygwailoHere's a patch that applies to Drupal 5.5. Well, except for deleting watchdog.info, which I got stuck on. Everything else applies to a stock Drupal 5.5 install, however.
Comment #8
sillygwailoHere's the patch for the newly-released Drupal 5.6. It even deletes watchdog.info for you!
Comment #9
sillygwailoA patch that applies to Drupal 5.7. (The patch for 5.6 applies just fine, with some offsets, but might as well make an 'official' version too.)
Comment #10
sillygwailoThe patch appears to apply nicely to a clean install of Drupal 5.8, so attaching a renamed file with the exact contents of previous patch.
Comment #11
sillygwailoSame with 5.9, the patch appears to apply cleanly. Attaching a renamed patch file, but the contents are exactly the same.
Comment #12
ipsocannibal CreditAttribution: ipsocannibal commentedI've noticed something strange on my drupal install, drupal 5.7, with this patch applied. After applying this patch whenever I set page caching to Normal I keep getting this error.
Fatal error: Call to undefined function arg() in "path to drupal install"/modules/dblog/dblog.module on line 88
This error corresponds to this method in the 5.7 version of the patch.
This function also appears in the 5.8 and 5.9 versions of the patch.
This is an excerpt from the drupal 5 api documentation of hook_init.
My question is does this patch really need to include a dblog_init() function? Shouldn't the body of dblog_init() in this patch go inside dblog_menu()? Is anybody else experiencing this kind of problem? This issue has been mention previously so why does dblog_init() still exist in the newer versions of the patch?
I've included a patch to the dblog.module file for the 5.7 version of the patch. It tested it and it seems to work. It should work for the 5.8 and 5.9 versions as well but I haven't been able to test it under those versions.
Comment #13
John Morahan CreditAttribution: John Morahan commentedCombined the two patches and rerolled for 5.10
Comment #14
kbahey CreditAttribution: kbahey commentedThe patch in #13 did not apply cleanly for me.
So, I rerolled another one that includes the fix in #12 for dblog complaining about arg().
It also contains another important fix: in some cases, php errors very early on cause watchdog() to be called, and if this is too early for watchdog to have been initialized, a WSOD can happen. So, the call to module_implements() is wrapped in a function_exists(), so this would not happen.
This can happen if you have for example an undefined variable in settings.php.
This patch has a fix for this.
Comment #15
kbahey CreditAttribution: kbahey commentedThe new modules were missing from the previous patch.
Here is an updated patch that includes the syslog and dblog patches.
Comment #16
sillygwailoA patch that applies to Drupal 5.14.
Comment #17
sillygwailoA patch that applies to Drupal 5.15. Only change from the previous patch is accounting for an offset.
Comment #18
sillygwailoA patch that applies to Drupal 5.19. Same as last comment, the only change is accounting for an offset.
Comment #19
sillygwailoThe patch in #18 applies cleanly to Drupal 5.20, but I'm attaching a renamed patch anyway. It's exactly the same as #18.
Comment #20
John Morahan CreditAttribution: John Morahan commentedfix suggested by litwol in irc: callback arguments should be an array (I have not tested)
Comment #21
John Morahan CreditAttribution: John Morahan commentedcvs version
Comment #22
John Morahan CreditAttribution: John Morahan commentedthat should be in !$may_cache too, shouldn't it.
Comment #23
johnhanley CreditAttribution: johnhanley commentedsubscribing
Comment #24
sillygwailoThe patch in #21 applies cleanly to Drupal 5.21. The patch attached is exactly the same as #21, except renamed with the most recent version number.
Comment #25
vito_a CreditAttribution: vito_a commentedThe http://drupal.org/files/issues/watchdog-hook-5.21-may_cache.patch in #24 applies cleanly to Drupal 5.22 , was tested on D5 version of the http://drupal.org/project/rawlog and seems to be working.
There is one more module implemeting this for D5, latest 5.21-5.22 versions support added in Rawlog version 1.0-alpha1 http://drupal.org/node/788922 , with the help of the http://drupal.org/files/issues/watchdog-hook-5.21-may_cache.patch patch. However patch still isn't part of the core despite being applied cleanly to Drupal 5.21 - 5.22.
As seems that there are many people who still use Drupal 5 and who need the hook_watchdog functionality in Drupal 5 and as D5 support and new versions release discontinues with the release of Drupal 7 which will happen soon, can someone please consider Drupal 5.23 and also including the the hook_watchdog functionality into Drupal 5.23?