You are here

function syslog_watchdog in Drupal 7

Same name and namespace in other branches
  1. 6 modules/syslog/syslog.module \syslog_watchdog()

Implements hook_watchdog().

File

modules/syslog/syslog.module, line 95

Code

function syslog_watchdog(array $log_entry) {
  global $base_url;
  $log_init =& drupal_static(__FUNCTION__, FALSE);
  if (!$log_init) {
    $log_init = TRUE;
    $default_facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER;
    openlog(variable_get('syslog_identity', 'drupal'), LOG_NDELAY, variable_get('syslog_facility', $default_facility));
  }
  $message = strtr(variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message'), array(
    '!base_url' => $base_url,
    '!timestamp' => $log_entry['timestamp'],
    '!type' => $log_entry['type'],
    '!ip' => $log_entry['ip'],
    '!request_uri' => $log_entry['request_uri'],
    '!referer' => $log_entry['referer'],
    '!uid' => $log_entry['uid'],
    '!link' => strip_tags($log_entry['link']),
    '!message' => strip_tags(!isset($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables'])),
  ));
  syslog($log_entry['severity'], $message);
}