You are here

private function LoggerDataCollector::sanitizeLogs in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php \Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector::sanitizeLogs()
1 call to LoggerDataCollector::sanitizeLogs()
LoggerDataCollector::lateCollect in vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php
Collects data as late as possible.

File

vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php, line 98

Class

LoggerDataCollector
LogDataCollector.

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

private function sanitizeLogs($logs) {
  $errorContextById = array();
  $sanitizedLogs = array();
  foreach ($logs as $log) {
    $context = $this
      ->sanitizeContext($log['context']);
    if (isset($context['type'], $context['file'], $context['line'], $context['level'])) {
      $errorId = md5("{$context['type']}/{$context['line']}/{$context['file']}\0{$log['message']}", true);
      $silenced = !($context['type'] & $context['level']);
      if (isset($errorContextById[$errorId])) {
        if (isset($errorContextById[$errorId]['errorCount'])) {
          ++$errorContextById[$errorId]['errorCount'];
        }
        else {
          $errorContextById[$errorId]['errorCount'] = 2;
        }
        if (!$silenced && isset($errorContextById[$errorId]['scream'])) {
          unset($errorContextById[$errorId]['scream']);
          $errorContextById[$errorId]['level'] = $context['level'];
        }
        continue;
      }
      $errorContextById[$errorId] =& $context;
      if ($silenced) {
        $context['scream'] = true;
      }
      $log['context'] =& $context;
      unset($context);
    }
    else {
      $log['context'] = $context;
    }
    $sanitizedLogs[] = $log;
  }
  return $sanitizedLogs;
}