You are here

function audit_log_syslog_audit_log in Audit Log 7

Implements hook_audit_log().

File

modules/audit_log_syslog/audit_log_syslog.module, line 10
Hook implementation for the Audit syslog logging module.

Code

function audit_log_syslog_audit_log(Auditlog $log) {
  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('audit_log_syslog_identity', variable_get('syslog_identity', 'drupal')), LOG_NDELAY, variable_get('audit_log_syslog_facility', variable_get('syslog_facility', $default_facility)));
  }
  $message = strtr(variable_get('audit_log_syslog_format', variable_get('syslog_format', '!base_url|!timestamp|!type|!ip|!request_uri|!referer|!uid|!link|!message')), array(
    '!base_url' => $base_url,
    '!ip' => ip_address(),
    '!timestamp' => $log->timestamp,
    '!type' => $log->audit_action,
    '!request_uri' => $base_url . '/' . $log->url,
    '!referer' => $base_url . '/' . $log->url,
    '!link' => $base_url . '/' . $log->url,
    '!uid' => $log->uid,
    '!entity_id' => $log->entity_id,
    '!entity_type' => $log->entity_type,
    '!entity_label' => $log->entity_label,
    '!bundle' => $log->bundle,
    '!audit_action' => $log->audit_action,
    '!message' => isset($log->message) ? $log->message : '',
  ));
  syslog(variable_get('audit_log_syslog_log_severity', WATCHDOG_NOTICE), $message);
}