1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 00:56:08 +02:00

Fix up #546 to json serialize correctly

This commit is contained in:
Jordi Boggiano
2015-06-01 21:42:42 +01:00
parent cbf17236e6
commit 1a1f506f0e
3 changed files with 10 additions and 7 deletions

View File

@@ -94,12 +94,15 @@ class NormalizerFormatter implements FormatterInterface
return $this->normalizeException($data);
}
$objData = $this->toJson($data, true);;
if(!$objData and method_exists($data, '__toString')) {
$objData = $data;
// non-serializable objects that implement __toString stringified
if (method_exists($data, '__toString') && !$data instanceof \JsonSerializable) {
$value = (string) $data;
} else {
// the rest is json-serialized in some way
$value = $this->toJson($data, true);
}
return sprintf("[object] (%s: %s)", get_class($data), $objData);
return sprintf("[object] (%s: %s)", get_class($data), $value);
}
if (is_resource($data)) {