How to use watchdog() in your own code
This function is invaluable for debugging your own code.
In its simplest form, one might use the following code to insert new lines into the watchdog log.
<?php
watchdog('error title', 'error message');
?>The watchdog module in modules/watchdog.module has everything but the function itself. You can find the watchdog() function in includes/bootstrap.inc where the parameters are explained:
<?php
// snippet taken from 4.7 -- includes/bootstrap.inc
/**
* Log a system message.
*
* @param $type
* The category to which this message belongs.
* @param $message
* The message to store in the log.
* @param $severity
* The severity of the message. One of the following values:
* - WATCHDOG_NOTICE
* - WATCHDOG_WARNING
* - WATCHDOG_ERROR
* @param $link
* A link to associate with the message.
*/
function watchdog($type, $message, $severity = WATCHDOG_NOTICE, $link = NULL) { ... }
?>