getLogData example



    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,
            ]
        );
    }
static::assertSame([
            'data' => [
                'customerId' => $customerId,
            ],
            'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
            'templateData' => [
                'user' => 'admin',
                'recoveryUrl' => 'http://some-url.com',
                'resetUrl' => 'http://some-url.com',
                'eventName' => CheckoutOrderPlacedEvent::EVENT_NAME,
            ],
        ]$event->getLogData());
    }
}
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,
        ]$event->getLogData());
    }
}
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',
            ],
        ]$event->getLogData());
        static::assertSame('mail.sent', $event->getName());
        static::assertSame($context$event->getContext());
        static::assertSame([
            'text/plain' => 'This is a plain text',
            'text/html' => 'This is a html text',
        ]$event->getContents());
    }
}
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());
        static::assertSame($context$event->getContext());
        static::assertSame($exception$event->getThrowable());
    }
}
Home | Imprint | This part of the site doesn't use cookies.