vendor/shopware/core/Framework/Log/LoggingService.php line 24

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Log;
  3. use Monolog\Logger;
  4. use Shopware\Core\Framework\Event\FlowLogEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * @internal
  8.  */
  9. #[Package('core')]
  10. class LoggingService implements EventSubscriberInterface
  11. {
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(
  16.         private readonly string $environment,
  17.         private readonly Logger $logger
  18.     ) {
  19.     }
  20.     public function logFlowEvent(FlowLogEvent $event): void
  21.     {
  22.         $innerEvent $event->getEvent();
  23.         $additionalData = [];
  24.         $logLevel Logger::DEBUG;
  25.         if ($innerEvent instanceof LogAware) {
  26.             $logLevel $innerEvent->getLogLevel();
  27.             $additionalData $innerEvent->getLogData();
  28.         }
  29.         $this->logger->addRecord(
  30.             $logLevel,
  31.             $innerEvent->getName(),
  32.             [
  33.                 'source' => 'core',
  34.                 'environment' => $this->environment,
  35.                 'additionalData' => $additionalData,
  36.             ]
  37.         );
  38.     }
  39.     public static function getSubscribedEvents(): array
  40.     {
  41.         return [FlowLogEvent::NAME => 'logFlowEvent'];
  42.     }
  43. }