You are here

function template_preprocess_errorlog_format in Logging and alerts 8

Same name and namespace in other branches
  1. 2.0.x errorlog/errorlog.module \template_preprocess_errorlog_format()

Prepares variables for errorlog format templates.

Default template: errorlog-format.html.twig.

File

errorlog/errorlog.module, line 40
Drupal Module: Web Server Logging and Alerts.

Code

function template_preprocess_errorlog_format(&$variables) {
  global $base_root;
  $config = \Drupal::config('system.site');
  $log_data = $variables['log'];
  $log_context = $variables['log']['context'];
  $severity_list = RfcLogLevel::getLevels();
  $message_body = new FormattableMarkup($log_data['message'], $log_context);
  $message = $config
    ->get('name') ?: 'Drupal';
  $message .= '|' . $base_root;
  $message .= '|severity=' . $severity_list[$log_data['level']];
  $message .= '|type=' . $log_context['channel'];
  $message .= '|ip=' . $log_context['ip'];
  $message .= '|uri=' . $log_context['request_uri'];
  $message .= '|referer=' . $log_context['referer'];
  $message .= '|uid=' . $log_context['uid'];
  $message .= '|link=' . strip_tags($log_context['link']);
  $message .= '|message=' . strip_tags($message_body);
  $variables['message'] = $message;
}