getLogLevel example

return $event;
            });

        $this->templateRenderer->expects(static::exactly(1))->method('render')->willThrowException(new \Exception('cannot render'));

        $email = $this->mailService->send($data, Context::createDefaultContext());

        static::assertNull($email);
        static::assertNotNull($beforeValidateEvent);
        static::assertInstanceOf(MailErrorEvent::class$mailErrorEvent);
        static::assertEquals(Level::Warning->value, $mailErrorEvent->getLogLevel());
        static::assertNotNull($mailErrorEvent->getMessage());

        $message = 'Could not render Mail-Template with error message: cannot render';

        static::assertSame($message$mailErrorEvent->getMessage());
        static::assertSame('Test email', $mailErrorEvent->getTemplate());
        static::assertSame([
            'salesChannel' => $salesChannel,
        ]$mailErrorEvent->getTemplateData());
    }

    
'text/plain' => 'This is a plain text',
                'text/html' => 'This is a html text',
            ],
            $context,
            CheckoutOrderPlacedEvent::EVENT_NAME,
        );

        static::assertSame([
            'john.doe@example.com' => 'John doe',
            'jane.doe@example.com' => 'Jane doe',
        ]$event->getRecipients());
        static::assertSame(Level::Info->value, $event->getLogLevel());
        static::assertSame('mail test', $event->getSubject());
        static::assertSame([
            'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
            'subject' => 'mail test',
            'recipients' => [
                'john.doe@example.com' => 'John doe',
                'jane.doe@example.com' => 'Jane doe',
            ],
            'contents' => [
                'text/plain' => 'This is a plain text',
                'text/html' => 'This is a html text',
            ],
'customerId' => $customerId,
            ],
            $context,
            [
                'user' => 'admin',
                'recoveryUrl' => 'http://some-url.com',
                'resetUrl' => 'http://some-url.com',
                'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
            ]
        );

        static::assertSame(Level::Info->value, $event->getLogLevel());
        static::assertSame('mail.before.send', $event->getName());
        static::assertSame($context$event->getContext());
        static::assertSame([
            'customerId' => $customerId,
        ]$event->getData());
        static::assertSame([
            'user' => 'admin',
            'recoveryUrl' => 'http://some-url.com',
            'resetUrl' => 'http://some-url.com',
            'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
        ]$event->getTemplateData());
        
Level::Error,
            $exception,
            'Test',
            '{{ subject }}',
            [
                'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
                'shopName' => 'Storefront',
            ],
        );

        static::assertSame('Test', $event->getMessage());
        static::assertSame(Level::Error->value, $event->getLogLevel());
        static::assertSame([
            'exception' => (string) $exception,
            'message' => 'Test',
            'template' => '{{ subject }}',
            'eventName' => 'checkout.order.placed',
            'templateData' => [
                'eventName' => 'checkout.order.placed',
                'shopName' => 'Storefront',
            ],
        ]$event->getLogData());
        static::assertSame('mail.sent.error', $event->getName());
        
 {
    }

    public function logFlowEvent(FlowLogEvent $event): void
    {
        $innerEvent = $event->getEvent();

        $additionalData = [];
        $logLevel = Level::Debug;

        if ($innerEvent instanceof LogAware) {
            $logLevel = $innerEvent->getLogLevel();
            $additionalData = $innerEvent->getLogData();
        }

        $this->logger->addRecord(
            $logLevel,
            $innerEvent->getName(),
            [
                'source' => 'core',
                'environment' => $this->environment,
                'additionalData' => $additionalData,
            ]
        );
->from(new Address('test@shopware.com'));

        $event = new MailBeforeSentEvent(
            [
                'customerId' => $customerId,
            ],
            $email,
            $context,
            CheckoutOrderPlacedEvent::EVENT_NAME
        );

        static::assertSame(Level::Info->value, $event->getLogLevel());
        static::assertSame('mail.after.create.message', $event->getName());
        static::assertSame($context$event->getContext());
        static::assertSame([
            'customerId' => $customerId,
        ]$event->getData());
        static::assertSame([
            'data' => [
                'customerId' => $customerId,
            ],
            'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
            'message' => $email,
        ],
Home | Imprint | This part of the site doesn't use cookies.