Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LoggerDataCollector.php

function LoggerDataCollector::getProcessedLogs

1 call to LoggerDataCollector::getProcessedLogs()
LoggerDataCollector::getFilters in vendor/symfony/http-kernel/DataCollector/LoggerDataCollector.php

File

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

Class

LoggerDataCollector
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\HttpKernel\DataCollector

Code

public function getProcessedLogs() : array {
    if (null !== $this->processedLogs) {
        return $this->processedLogs;
    }
    $rawLogs = $this->getLogs();
    if ([] === $rawLogs) {
        return $this->processedLogs = $rawLogs;
    }
    $logs = [];
    foreach ($this->getLogs()
        ->getValue() as $rawLog) {
        $rawLogData = $rawLog->getValue();
        if ($rawLogData['priority']->getValue() > 300) {
            $logType = 'error';
        }
        elseif (isset($rawLogData['scream']) && false === $rawLogData['scream']->getValue()) {
            $logType = 'deprecation';
        }
        elseif (isset($rawLogData['scream']) && true === $rawLogData['scream']->getValue()) {
            $logType = 'silenced';
        }
        else {
            $logType = 'regular';
        }
        $logs[] = [
            'type' => $logType,
            'errorCount' => $rawLog['errorCount'] ?? 1,
            'timestamp' => $rawLogData['timestamp_rfc3339']->getValue(),
            'priority' => $rawLogData['priority']->getValue(),
            'priorityName' => $rawLogData['priorityName']->getValue(),
            'channel' => $rawLogData['channel']->getValue(),
            'message' => $rawLogData['message'],
            'context' => $rawLogData['context'],
        ];
    }
    // sort logs from oldest to newest
    usort($logs, static fn($logA, $logB) => $logA['timestamp'] <=> $logB['timestamp']);
    return $this->processedLogs = $logs;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal