function hook_watchdog

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 system.api.php hook_watchdog(array $log_entry)
cle7 system.api.php hook_watchdog(array $log_entry)
elmsmedia7 system.api.php hook_watchdog(array $log_entry)
icor7 system.api.php hook_watchdog(array $log_entry)
meedjum_blog7 system.api.php hook_watchdog(array $log_entry)
mooc7 system.api.php hook_watchdog(array $log_entry)

Log an event message.

This hook allows modules to route log events to custom destinations, such as SMS, Email, pager, syslog, ...etc.

Parameters

$log_entry: An associative array containing the following keys:

  • type: The type of message for this entry.
  • user: The user object for the user who was logged in when the event happened.
  • uid: The user ID for the user who was logged in when the event happened.
  • request_uri: The request URI for the page the event happened in.
  • referer: The page that referred the user to the page where the event occurred.
  • ip: The IP address where the request for the page came from.
  • timestamp: The UNIX timestamp of the date/time the event occurred.
  • severity: The severity of the message; one of the following values as defined in RFC 3164:

  • link: An optional link provided by the module that called the watchdog() function.
  • message: The text of the message to be logged. Variables in the message are indicated by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how the message and variable parameters interact.
  • variables: An array of variables to be inserted into the message on display. Will be NULL or missing if a message is already translated or if the message is not possible to translate.

Related topics

6 functions implement hook_watchdog()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

actions_loop_test_watchdog in modules/simpletest/tests/actions_loop_test.module
Implements hook_watchdog().
cis_remote_watchdog_watchdog in sites/all/modules/elmsln_contrib/cis_connector/modules/cis_remote_watchdog/cis_remote_watchdog.module
Impements hook_watchdog().
dblog_watchdog in modules/dblog/dblog.module
Implements hook_watchdog().
devel_watchdog in sites/all/modules/ulmus/devel/devel.module
Implements hook_watchdog().
entity_cache_test_watchdog in modules/simpletest/tests/entity_cache_test.module
Implements hook_watchdog().

... See full list

3 invocations of hook_watchdog()
entity_watchdog_entity_insert in sites/all/modules/elmsln_contrib/entity_watchdog/entity_watchdog.module
Implements hook_entity_insert($entity, $type).
watchdog in includes/bootstrap.inc
Logs a system message.
watchdog_skip_semaphore in modules/simpletest/tests/actions_loop_test.module
Replacement of the watchdog() function that eliminates the use of semaphores so that we can test the abortion of an action loop.

File

modules/system/system.api.php, line 2438
Hooks provided by Drupal core and the System module.

Code

function hook_watchdog(array $log_entry) {
  global $base_url, $language;

  $severity_list = array(
    WATCHDOG_EMERGENCY => t('Emergency'),
    WATCHDOG_ALERT => t('Alert'),
    WATCHDOG_CRITICAL => t('Critical'),
    WATCHDOG_ERROR => t('Error'),
    WATCHDOG_WARNING => t('Warning'),
    WATCHDOG_NOTICE => t('Notice'),
    WATCHDOG_INFO => t('Info'),
    WATCHDOG_DEBUG => t('Debug'),
  );

  $to = 'someone@example.com';
  $params = array();
  $params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array(
    '@site_name' => variable_get('site_name', 'Drupal'),
    '@severity_desc' => $severity_list[$log_entry['severity']],
  ));

  $params['message'] = "\nSite:         @base_url";
  $params['message'] .= "\nSeverity:     (@severity) @severity_desc";
  $params['message'] .= "\nTimestamp:    @timestamp";
  $params['message'] .= "\nType:         @type";
  $params['message'] .= "\nIP Address:   @ip";
  $params['message'] .= "\nRequest URI:  @request_uri";
  $params['message'] .= "\nReferrer URI: @referer_uri";
  $params['message'] .= "\nUser:         (@uid) @name";
  $params['message'] .= "\nLink:         @link";
  $params['message'] .= "\nMessage:      \n\n@message";

  $params['message'] = t($params['message'], array(
    '@base_url' => $base_url,
    '@severity' => $log_entry['severity'],
    '@severity_desc' => $severity_list[$log_entry['severity']],
    '@timestamp' => format_date($log_entry['timestamp']),
    '@type' => $log_entry['type'],
    '@ip' => $log_entry['ip'],
    '@request_uri' => $log_entry['request_uri'],
    '@referer_uri' => $log_entry['referer'],
    '@uid' => $log_entry['uid'],
    '@name' => $log_entry['user']->name,
    '@link' => strip_tags($log_entry['link']),
    '@message' => strip_tags($log_entry['message']),
  ));

  drupal_mail('emaillog', 'entry', $to, $language, $params);
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.