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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Log;
  3. use Monolog\Logger;
  4. use Shopware\Core\Framework\Event\BusinessEvent;
  5. use Shopware\Core\Framework\Event\BusinessEvents;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class LoggingService implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var Logger
  11.      */
  12.     protected $logger;
  13.     /**
  14.      * @var array
  15.      */
  16.     protected $subscribedEvents;
  17.     /**
  18.      * @var string
  19.      */
  20.     protected $environment;
  21.     public function __construct(
  22.         string $kernelEnv,
  23.         Logger $logger
  24.     ) {
  25.         $this->logger $logger;
  26.         $this->environment $kernelEnv;
  27.     }
  28.     public function logBusinessEvent(BusinessEvent $event): void
  29.     {
  30.         $innerEvent $event->getEvent();
  31.         $additionalData = [];
  32.         $logLevel Logger::DEBUG;
  33.         if ($innerEvent instanceof LogAwareBusinessEventInterface) {
  34.             $logLevel $innerEvent->getLogLevel();
  35.             $additionalData $innerEvent->getLogData();
  36.         }
  37.         $this->logger->addRecord(
  38.             $logLevel,
  39.             $innerEvent->getName(),
  40.             [
  41.                 'source' => 'core',
  42.                 'environment' => $this->environment,
  43.                 'additionalData' => $additionalData,
  44.             ]
  45.         );
  46.     }
  47.     public static function getSubscribedEvents(): array
  48.     {
  49.         return [BusinessEvents::GLOBAL_EVENT => 'logBusinessEvent'];
  50.     }
  51. }