Home ›
Calling watchdog function (logging info) in Drupal 6Calling watchdog function (logging info) in Drupal 6
Submitted by Benjamin Melançon on October 31, 2008 - 2:58am
In Drupal 6, the way watchdog() is used has changed a bit.
It's all defined in the API, of course, but some things could use a little more clarification.
Here's the function definition as a starting point:
http://api.drupal.org/api/function/watchdog/6
<?php
function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
?>
And Agaric's explanation of watchdog's parameters, in we hope something closer to layman's terms:
- $type is typically the module name (the module from which you are calling watchdog).
- $message is your error message. You can use percent-style (and I suppose other) placeholders (%placeholder) but do not wrap your text in the t() function— this function will be called by the various implementations of hook_watchdog.
- $variables is an array holding your placeholders in '%placeholder' => $placeholder syntax.
- $severity is what you might have been thinking for "type." watchdog_severity_levels defines a slew of them, but you will probably most often be using the default WATCHDOG_NOTICE or replacing it with WATCHDOG_ERROR.
See a simple example of watchdog being called in action (er, honestly, no pun intended) in actions_save().
Resolution
Searched words:
logging reports D6 save error or notice information to watchdog table
log notices, errors, alerts the Drupal way
Comments
+1
+1
Post new comment