30 lines
678 B
PHP
30 lines
678 B
PHP
<?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->error($event->getThrowable()->getMessage());
|
|
}
|
|
} |