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

Make gelf formatter extend the normalizer one

This commit is contained in:
Jordi Boggiano
2012-04-22 17:38:31 +02:00
parent 985e682079
commit 56d246cca3
3 changed files with 18 additions and 26 deletions

View File

@@ -76,12 +76,15 @@ class NormalizerFormatter implements FormatterInterface
return '[resource]';
}
return sprintf("[object] (%s: %s)", get_class($data), $this->toJson($data));
}
protected function toJson($data)
{
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
$encoded = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
} else {
$encoded = json_encode($data);
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
return sprintf("[object] (%s: %s)", get_class($data), $encoded);
return json_encode($data);
}
}