mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-01 19:00:20 +02:00
Fix gelf formatter keys to strip invalid characters, fixes #1927
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Monolog;
|
||||
|
||||
class_alias(JsonSerializableDateTimeImmutable::class, 'Monolog\DateTimeImmutable');
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
if (false) {
|
||||
/**
|
||||
* @deprecated Use \Monolog\JsonSerializableDateTimeImmutable instead.
|
||||
|
@@ -115,6 +115,7 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
}
|
||||
|
||||
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 @@ class GelfMessageFormatter extends NormalizerFormatter
|
||||
}
|
||||
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user