mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-22 09:06:10 +02:00
Catch json_encode recursion error
This commit is contained in:
@@ -54,16 +54,24 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
|
||||
$record = $this->normalize($record);
|
||||
$message = array('message' => $record['message']);
|
||||
$handleError = false;
|
||||
if ($record['context']) {
|
||||
$message['context'] = $record['context'];
|
||||
$handleError = true;
|
||||
}
|
||||
if ($record['extra']) {
|
||||
$message['extra'] = $record['extra'];
|
||||
$handleError = true;
|
||||
}
|
||||
if (count($message) === 1) {
|
||||
$message = reset($message);
|
||||
}
|
||||
|
||||
// Handle json_encode recursion error
|
||||
if ($handleError) {
|
||||
set_error_handler(function () { });
|
||||
}
|
||||
|
||||
// Create JSON object describing the appearance of the message in the console
|
||||
$json = json_encode(array(
|
||||
array(
|
||||
@@ -75,6 +83,10 @@ class WildfireFormatter extends NormalizerFormatter
|
||||
$message,
|
||||
));
|
||||
|
||||
if ($handleError) {
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
// The message itself is a serialization of the above JSON object + it's length
|
||||
return sprintf(
|
||||
'%s|%s|',
|
||||
|
Reference in New Issue
Block a user