mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 13:46:38 +02:00
Convert GelfMessage into string required by createAmqpMessage (#1869)
* Convert GelfMessage into string required by createAmqpMessage * Convert object on write() too
This commit is contained in:
committed by
GitHub
parent
35dab43e3c
commit
814ea500f8
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Monolog\Handler;
|
namespace Monolog\Handler;
|
||||||
|
|
||||||
|
use Gelf\Message as GelfMessage;
|
||||||
use Monolog\Level;
|
use Monolog\Level;
|
||||||
use Monolog\Formatter\FormatterInterface;
|
use Monolog\Formatter\FormatterInterface;
|
||||||
use Monolog\Formatter\JsonFormatter;
|
use Monolog\Formatter\JsonFormatter;
|
||||||
@@ -75,6 +76,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
|||||||
$data = $record->formatted;
|
$data = $record->formatted;
|
||||||
$routingKey = $this->getRoutingKey($record);
|
$routingKey = $this->getRoutingKey($record);
|
||||||
|
|
||||||
|
if($data instanceof GelfMessage) {
|
||||||
|
$data = json_encode($data->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->exchange instanceof AMQPExchange) {
|
if ($this->exchange instanceof AMQPExchange) {
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'delivery_mode' => 2,
|
'delivery_mode' => 2,
|
||||||
@@ -117,6 +122,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
|||||||
$record = $this->processRecord($record);
|
$record = $this->processRecord($record);
|
||||||
$data = $this->getFormatter()->format($record);
|
$data = $this->getFormatter()->format($record);
|
||||||
|
|
||||||
|
if($data instanceof GelfMessage) {
|
||||||
|
$data = json_encode($data->toArray());
|
||||||
|
}
|
||||||
|
|
||||||
$this->exchange->batch_basic_publish(
|
$this->exchange->batch_basic_publish(
|
||||||
$this->createAmqpMessage($data),
|
$this->createAmqpMessage($data),
|
||||||
$this->exchangeName,
|
$this->exchangeName,
|
||||||
|
Reference in New Issue
Block a user