From 3101f1c09a0e5a2be11460c33ca09565db6780bf Mon Sep 17 00:00:00 2001 From: Leny BERNARD Date: Fri, 13 May 2016 15:17:26 +0200 Subject: [PATCH] check if val is null to avoid to set the string "null" instead of null --- src/Monolog/Formatter/GelfMessageFormatter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Formatter/GelfMessageFormatter.php b/src/Monolog/Formatter/GelfMessageFormatter.php index b4de509d..64e76652 100644 --- a/src/Monolog/Formatter/GelfMessageFormatter.php +++ b/src/Monolog/Formatter/GelfMessageFormatter.php @@ -106,7 +106,7 @@ class GelfMessageFormatter extends NormalizerFormatter } foreach ($record['extra'] as $key => $val) { - $val = is_scalar($val) ? $val : $this->toJson($val); + $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); $len += strlen($this->extraPrefix . $key . $val); if ($len > self::MAX_LENGTH) { $message->setAdditional($this->extraPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len)); @@ -116,7 +116,7 @@ class GelfMessageFormatter extends NormalizerFormatter } foreach ($record['context'] as $key => $val) { - $val = is_scalar($val) ? $val : $this->toJson($val); + $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); $len += strlen($this->contextPrefix . $key . $val); if ($len > self::MAX_LENGTH) { $message->setAdditional($this->contextPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len));