Вход Регистрация
Файл: vendor/laravel/framework/src/Illuminate/Container/Attributes/Log.php
Строк: 92
<?php

namespace IlluminateContainerAttributes;

use 
Attribute;
use 
IlluminateContractsContainerContainer;
use 
IlluminateContractsContainerContextualAttribute;
use 
UnitEnum;

use function 
IlluminateSupportenum_value;

#[Attribute(Attribute::TARGET_PARAMETER)]
class Log implements ContextualAttribute
{
    
/**
     * Create a new class instance.
     *
     * @param  UnitEnum|string|null  $channel  The log configuration's channel name.
     * @param  UnitEnum|string|null  $name  The name to prefix all logs with. Only to be used with Monolog drivers.
     */
    
public function __construct(
        public 
UnitEnum|string|null $channel null,
        public 
UnitEnum|string|null $name null,
    ) {
    }

    
/**
     * Resolve the log channel.
     *
     * @param  self  $attribute
     * @param  IlluminateContractsContainerContainer  $container
     * @return PsrLogLoggerInterface
     */
    
public static function resolve(self $attributeContainer $container)
    {
        
$logger $container->make('log')->channel(enum_value($attribute->channel));

        if (
$attribute->name !== null) {
            
$logger $logger->withName(enum_value($attribute->name));
        }

        return 
$logger;
    }
}
Онлайн: 3
Реклама