You are here

function logs_http_register_event in Logs HTTP 7

Register an event in a static cache.

To prevent multiple registration of the same error, we check that identical events are not captured twice, thus reducing the final HTTP requests needed.

Parameters

array $log_entry: The entry log as passed from hook_watchdog().

1 call to logs_http_register_event()
logs_http_watchdog in ./logs_http.module
Implements hook_watchdog().

File

./logs_http.module, line 123
Logs HTTP module.

Code

function logs_http_register_event(array $log_entry) {
  if (!logs_http_get_http_url()) {
    return;
  }
  $events =& drupal_static('logs_http_events', array());
  $event = array(
    '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' => empty($log_entry['variables']) ? $log_entry['message'] : strtr($log_entry['message'], $log_entry['variables']),
    'severity' => $log_entry['severity'],
  );
  if (!empty($log_entry['variables']['exception_trace'])) {

    // @todo: We avoid unserializing as it seems to causes Logs to fail
    // to index event as JSON.
    $event['exception_trace'] = base64_decode($log_entry['variables']['exception_trace']);
  }
  if ($uuid = variable_get('logs_http_uuid')) {
    $event['uuid'] = $uuid;
  }

  // Remove empty values, to prevent errors in the indexing of the JSON.
  $event = logs_http_array_remove_empty($event);

  // Prevent identical events.
  $event_clone = $event;
  unset($event_clone['timestamp']);
  $key = md5(serialize($event_clone));
  $events[$key] = $event;
}