<?php

declare(strict_types=1);

namespace App\Framework\Logging;

use App\Framework\Logging\ValueObjects\LogContext;

/**
 * Standard-Implementation für Channel-spezifisches Logging
 *
 * Delegiert alle Log-Aufrufe an den übergeordneten Logger mit dem spezifischen Channel.
 * Ermöglicht die elegante API: $logger->security->error('message')
 */
final readonly class DefaultChannelLogger implements Logger, HasChannel
{
    public function __construct(
        private SupportsChannels $parentLogger,
        public LogChannel $channel
    ) {
    }

    public function debug(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::DEBUG, $message, $context);
    }

    public function info(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::INFO, $message, $context);
    }

    public function notice(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::NOTICE, $message, $context);
    }

    public function warning(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::WARNING, $message, $context);
    }

    public function error(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::ERROR, $message, $context);
    }

    public function critical(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::CRITICAL, $message, $context);
    }

    public function alert(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::ALERT, $message, $context);
    }

    public function emergency(string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, LogLevel::EMERGENCY, $message, $context);
    }

    public function log(LogLevel $level, string $message, ?LogContext $context = null): void
    {
        $this->parentLogger->logToChannel($this->channel, $level, $message, $context);
    }
}
