Drupal 5.1 backport of watchdog hook for custom logging and alerts via module
| Project: | Drupal |
| Version: | 5.x-dev |
| Component: | watchdog.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | kbahey |
| Status: | won't fix |
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.
| Attachment | Size |
|---|---|
| logging-5.1-4.patch | 37.32 KB |

#1
Correct, this will not go into 5.x.
#2
dblog.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 98The 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.
#3
Patch was malformed. Trying again.
#4
I 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
#5
xx (wrong project, sorry)
#6
(xx)
#7
Here'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.
#8
Here's the patch for the newly-released Drupal 5.6. It even deletes watchdog.info for you!
#9
A 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.)