watchdog

Definition

watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL)
includes/bootstrap.inc, line 803

Description

Log a system message.

See also

watchdog_severity_levels()

Parameters

$type The category to which this message belongs.

$message The message to store in the log. See t() for documentation on how $message and $variables interact. Keep $message translatable by not concatenating dynamic values into it!

$variables Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.

$severity The severity of the message, as per RFC 3164

$link A link to associate with the message.

Code

<?php
function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
  global $user, $base_root;

  // Prepare the fields to be logged
  $log_message = array(
    'type'        => $type,
    'message'     => $message,
    'variables'   => $variables,
    'severity'    => $severity,
    'link'        => $link,
    'user'        => $user,
    'request_uri' => $base_root . request_uri(),
    'referer'     => referer_uri(),
    'ip'          => ip_address(),
    'timestamp'   => time(),
    );

  // Call the logging hooks to log/process the message
  foreach (module_implements('watchdog', TRUE) as $module) {
    module_invoke($module, 'watchdog', $log_message);
  }
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.