Seldaek/monolog

GelfMessageFormatter and content/extra as numeric array

Opened this issue · 0 comments

Monolog version 3.8.1

GelfMessageFormatter::format throws an exception if any of the context or extra properties in the LogRecord argument contains a numeric array..

Exception:

preg_replace(): Argument #3 ($subject) must be of type array|string, int given

Thats of course due to strict_types=1 and this:
https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/GelfMessageFormatter.php#L118
https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/GelfMessageFormatter.php#L130

I'm not sure if this type of message is what you expected to receive, but some libraries, like the Elasticsearch client, send messages like this. Therefore, the logger shouldn't throw an exception in such cases.