getHttpConfiguration()->getEndpoint(), FILTER_VALIDATE_URL)) { return false; } return true; } /** * @inheritDoc */ public static function handleEvent(Application $application, Event $event): void { $header = match($application->getHttpConfiguration()->getLogFormat()) { LogFormat::JSONL => 'Content-Type: application/json', LogFormat::CSV => 'Content-Type: text/csv', LogFormat::TXT => 'Content-Type: text/plain', LogFormat::XML => 'Content-Type: text/xml', LogFormat::HTML => 'Content-Type: text/html', }; $message = $application->getHttpConfiguration()->getLogFormat()->format( $application->getHttpConfiguration()->getTimestampFormat(), $application->getHttpConfiguration()->getTraceFormat(), $event ); if($application->getHttpConfiguration()->isAppendNewline()) { $message .= PHP_EOL; } // Note, no exception handling is done here. If the HTTP request fails, it will fail silently. $ch = curl_init($application->getHttpConfiguration()->getEndpoint()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $message); curl_setopt($ch, CURLOPT_HTTPHEADER, [$header]); curl_exec($ch); curl_close($ch); } }