You are here

watchdog_rules.module in Logging and alerts 6

Provides a Rules integration for wachdog events.

File

watchdog_rules/watchdog_rules.module
View source
<?php

/**
 * @file
 * Provides a Rules integration for wachdog events.
 */

/**
 * Implementation of hook_watchdog().
 */
function watchdog_rules_watchdog($watchdog_message) {
  rules_invoke_event('watchdog_rules', $watchdog_message['user'], $watchdog_message);
}

/**
 * Implementation of hook_token_list().
 */
function watchdog_rules_token_list($type = 'all') {
  if ($type == 'watchdog' || $type == 'all') {
    $tokens['watchdog_rules'] = array(
      'type' => t('The type of the watchdog event.'),
      'request_uri' => t('The request URI for the page the event happened in.'),
      'referer' => t('The page that referred the user to the page where the event occurred.'),
      'ip' => t('The IP address where the request for the page came from.'),
      'timestamp' => t('The UNIX timetamp of the date/time the event occurred.'),
      'severity' => t('The degree of severity of the event.'),
      'link' => t('An informational link provided by the module calling watchdog.'),
      'message' => t('The text of the message to be logged.'),
    );
    return $tokens;
  }
}

/**
 * Implementation of hook_token_values().
 */
function watchdog_rules_token_values($type, $object = NULL, $options = array()) {
  $tokens = array();
  if ($type == 'watchdog' || $type == 'all') {
    $tokens = array(
      'type' => $object['type'],
      'request_uri' => $object['request_uri'],
      'referer' => $object['referer'],
      'ip' => $object['ip'],
      'timestamp' => $object['timestamp'],
      'severity' => $object['severity'],
      'link' => $object['link'],
      'message' => $object['message'],
    );
    return $tokens;
  }
}

Functions

Namesort descending Description
watchdog_rules_token_list Implementation of hook_token_list().
watchdog_rules_token_values Implementation of hook_token_values().
watchdog_rules_watchdog Implementation of hook_watchdog().