src/Core/Subscriber/LoggerSubscriber.php line 28

Open in your IDE?
  1. <?php
  2. namespace Bodymed\Webshop\Core\Subscriber;
  3. use Psr\Log\LoggerInterface;
  4. use Shopware\Core\Content\MailTemplate\Service\Event\MailErrorEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class LoggerSubscriber implements EventSubscriberInterface
  7. {
  8.     private LoggerInterface $logger;
  9.     /**
  10.      * @param LoggerInterface $logger
  11.      */
  12.     public function __construct(LoggerInterface $logger)
  13.     {
  14.         $this->logger $logger;
  15.     }
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             MailErrorEvent::class => 'onMailErrorEvent',
  20.         ];
  21.     }
  22.     public function onMailErrorEvent(MailErrorEvent $errorEvent): void
  23.     {
  24.         $this->logger->log($errorEvent->getLogLevel(), $errorEvent->getMessage(), $errorEvent->getLogData());
  25.     }
  26. }