Agregar usuario a log
This commit is contained in:
18
app/common/Implement/Log/UserProcessor.php
Normal file
18
app/common/Implement/Log/UserProcessor.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user