for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the php-gelf package.
*
* (c) Benjamin Zikarsky <http://benjamin-zikarsky.de>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gelf\Encoder;
use Gelf\MessageInterface;
/**
* The JsonEncoder allows the encoding of GELF messages as described
* in http://www.graylog2.org/resources/documentation/sending/gelfhttp
* @author Benjamin Zikarsky <[email protected]>
class JsonEncoder implements NoNullByteEncoderInterface
{
* @inheritDoc
public function encode(MessageInterface $message): string
return $this->jsonEncode($message->toArray());
}
private function jsonEncode(mixed $data): string
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);