1 syslog.module syslog_watchdog(array $log_entry)

Implements hook_watchdog().

File

core/modules/syslog/syslog.module, line 89
Redirects logging messages to syslog.

Code

function syslog_watchdog(array $log_entry) {
  global $base_url;

  $log_init = &backdrop_static(__FUNCTION__, FALSE);
  $config = config('system.core');

  if (!$log_init) {
    $log_init = TRUE;
    $facility = $config->get('log_facility');
    if ($facility === '') {
      $facility = defined('LOG_LOCAL0') ? LOG_LOCAL0 : LOG_USER;
    }
    openlog($config->get('log_identity'), LOG_NDELAY, $facility);
  }

  $message = strtr($config->get('log_format'), 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);
}