<?php
namespace Incoviba\Common\Implement\Log;

use Monolog\LogRecord;
use Monolog\Processor\ProcessorInterface;
use Incoviba\Service;

class UserProcessor implements ProcessorInterface
{
    public function __construct(protected Service\Login $loginService) {}
    public function __invoke(LogRecord $record): LogRecord
    {
        if ($this->loginService->isIn()) {
            $record->extra['user'] = $this->loginService->getUser()->name;
        }
        return $record;
    }
}
