mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 13:16:39 +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;
|
||||
|
||||
use Gelf\Message as GelfMessage;
|
||||
use Monolog\Level;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
@@ -75,6 +76,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
||||
$data = $record->formatted;
|
||||
$routingKey = $this->getRoutingKey($record);
|
||||
|
||||
if($data instanceof GelfMessage) {
|
||||
$data = json_encode($data->toArray());
|
||||
}
|
||||
|
||||
if ($this->exchange instanceof AMQPExchange) {
|
||||
$attributes = [
|
||||
'delivery_mode' => 2,
|
||||
@@ -117,6 +122,10 @@ class AmqpHandler extends AbstractProcessingHandler
|
||||
$record = $this->processRecord($record);
|
||||
$data = $this->getFormatter()->format($record);
|
||||
|
||||
if($data instanceof GelfMessage) {
|
||||
$data = json_encode($data->toArray());
|
||||
}
|
||||
|
||||
$this->exchange->batch_basic_publish(
|
||||
$this->createAmqpMessage($data),
|
||||
$this->exchangeName,
|
||||
|
Reference in New Issue
Block a user