<?php

namespace App\Framework\Logging\Handlers;

use App\Framework\Database\DatabaseManager;
use App\Framework\Logging\LogHandler;
use App\Framework\Logging\LogLevel;
use App\Framework\Logging\LogRecord;
use App\Framework\Logging\ProcessLogCommand;
use App\Framework\Queue\Queue;

final readonly class QueuedLogHandler implements LogHandler
{
    public function __construct(
        private Queue $queue,
        #private LogLevel $minLevel = LogLevel::INFO,
    ){}

    public function isHandling(LogRecord $record): bool
    {
        return true;
    }

    public function handle(LogRecord $record): void
    {
        $job = new ProcessLogCommand($record);
        $this->queue->push($job);
    }
}
