skipClassesPartials = $skipClassesPartials; $this->skipStackFrames = $skipStackFrames; } /** * Verarbeitet einen Log-Record und fügt Introspection-Daten hinzu */ public function processRecord(LogRecord $record): LogRecord { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); // Überspringe Stack-Frames, die zur Logger-Infrastruktur gehören $i = $this->skipStackFrames; $framesCount = count($trace); // Suche nach dem ersten Frame, der nicht zu ignorieren ist while ($i < $framesCount) { if (isset($trace[$i]['class'])) { foreach ($this->skipClassesPartials as $partial) { if (str_starts_with($trace[$i]['class'], $partial)) { $i++; continue 2; // Zum nächsten Frame wechseln } } } break; // Frame gefunden, der nicht ignoriert werden soll } // Sicherstellen, dass wir einen gültigen Frame haben if ($i >= $framesCount) { return $record; // Kein passender Frame gefunden } // Introspection-Daten extrahieren $frame = $trace[$i]; $introspection = [ 'file' => $frame['file'] ?? 'unknown', 'line' => $frame['line'] ?? 0, 'class' => $frame['class'] ?? '', 'function' => $frame['function'] ?? '', ]; // Zu den Extra-Daten hinzufügen return $record->addExtra('introspection', $introspection); } /** * Gibt die Priorität des Processors zurück */ public function getPriority(): int { return self::PRIORITY; } /** * Gibt einen eindeutigen Namen für den Processor zurück */ public function getName(): string { return 'introspection'; } }