add logging #47
30
src/Subcriber.php
Normal file
30
src/Subcriber.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class Subcriber implements EventSubscriberInterface
|
||||
{
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
KernelEvents::EXCEPTION => 'logException'
|
||||
];
|
||||
}
|
||||
|
||||
public function logException(ExceptionEvent $event): void
|
||||
{
|
||||
$this->logger->warning($event->getThrowable()->getMessage());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user