<?php
declare(strict_types=1);

namespace CloudXM\SDK\Events;

use Monolog\LogRecord;

/**
 * Event dispatched before log filtering to allow plugins to apply custom filtering rules.
 */
final class LogFilterEvent
{
    private LogRecord $record;
    private bool $shouldSendToRemote;

    public function __construct(LogRecord $record, bool $shouldSendToRemote = true)
    {
        $this->record = $record;
        $this->shouldSendToRemote = $shouldSendToRemote;
    }

    public function getRecord(): LogRecord
    {
        return $this->record;
    }

    public function shouldSendToRemote(): bool
    {
        return $this->shouldSendToRemote;
    }

    public function setShouldSendToRemote(bool $shouldSendToRemote): void
    {
        $this->shouldSendToRemote = $shouldSendToRemote;
    }

    /**
     * Prevent further filtering if this returns true
     */
    public function stopPropagation(): void
    {
        $this->shouldSendToRemote = false;
    }
}