diff --git a/src/Monolog/DateTimeImmutable.php b/src/Monolog/DateTimeImmutable.php index 968c58a6b..3cb7086d7 100644 --- a/src/Monolog/DateTimeImmutable.php +++ b/src/Monolog/DateTimeImmutable.php @@ -13,6 +13,7 @@ class_alias(JsonSerializableDateTimeImmutable::class, 'Monolog\DateTimeImmutable'); +// @phpstan-ignore-next-line if (false) { /** * @deprecated Use \Monolog\JsonSerializableDateTimeImmutable instead. diff --git a/src/Monolog/Formatter/GelfMessageFormatter.php b/src/Monolog/Formatter/GelfMessageFormatter.php index 9b0861948..d169e1b61 100644 --- a/src/Monolog/Formatter/GelfMessageFormatter.php +++ b/src/Monolog/Formatter/GelfMessageFormatter.php @@ -115,6 +115,7 @@ public function format(LogRecord $record): Message } foreach ($extra as $key => $val) { + $key = (string) preg_replace('#[^\w\.\-]#', '-', $key); $val = \is_scalar($val) || null === $val ? $val : $this->toJson($val); $len = \strlen($this->extraPrefix . $key . $val); if ($len > $this->maxLength) { @@ -126,6 +127,7 @@ public function format(LogRecord $record): Message } foreach ($context as $key => $val) { + $key = (string) preg_replace('#[^\w\.\-]#', '-', $key); $val = \is_scalar($val) || null === $val ? $val : $this->toJson($val); $len = \strlen($this->contextPrefix . $key . $val); if ($len > $this->maxLength) {