1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

check if val is null to avoid to set the string "null" instead of null

This commit is contained in:
Leny BERNARD
2016-05-13 15:17:26 +02:00
committed by Jordi Boggiano
parent 83a24937ba
commit 3101f1c09a

View File

@@ -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));