<?php

declare(strict_types=1);

namespace App\Framework\Logging\Processors;

use App\Framework\Logging\LogProcessor;
use App\Framework\Logging\LogRecord;
use App\Framework\Logging\Metrics\LogMetricsCollector;

/**
 * Metrics Collecting Processor
 *
 * Sammelt automatisch Metriken für jeden Log-Eintrag.
 */
final readonly class MetricsCollectingProcessor implements LogProcessor
{
    public function __construct(
        private LogMetricsCollector $collector
    ) {
    }

    public function processRecord(LogRecord $record): LogRecord
    {
        $this->collector->recordLog($record->level, $record->channel);

        return $record;
    }

    public function getPriority(): int
    {
        return 100; // Sehr früh, um alles zu erfassen
    }

    public function getName(): string
    {
        return 'metrics_collecting';
    }
}
