summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Horrigan <dan@dhorrigan.com>2014-03-18 16:43:13 -0400
committerDan Horrigan <dan@dhorrigan.com>2014-03-18 16:43:13 -0400
commitae301cfcab37ad8f1e2d2e2833f09d2477769727 (patch)
treefbbba42aee66fb917c5e5ed3feba4d89a064df9b
parent1d7b9247010ad829ffb1a121d7f7e1d7dd8cac04 (diff)
downloadKLogger-ae301cfcab37ad8f1e2d2e2833f09d2477769727.zip
KLogger-ae301cfcab37ad8f1e2d2e2833f09d2477769727.tar.gz
KLogger-ae301cfcab37ad8f1e2d2e2833f09d2477769727.tar.bz2
Better var_export formatting.
-rwxr-xr-xsrc/Logger.php27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Logger.php b/src/Logger.php
index d007b0c..7a10775 100755
--- a/src/Logger.php
+++ b/src/Logger.php
@@ -200,18 +200,21 @@ class Logger extends AbstractLogger
*/
private function contextToString($context)
{
- $export = var_export($context, true);
-
- // var_export is ugly, let's pretty it up a bit.
- return preg_replace(array(
- '/=>\s+([a-zA-Z])/im',
- '/array\(\s+\)/im',
- '/^ |\G /m',
- ), array(
- '=> $1',
- 'array()',
- ' ',
- ), str_replace('array (', 'array(', $export));
+ $export = '';
+ foreach ($context as $key => $value) {
+ $export .= "{$key}: ";
+ $export .= preg_replace(array(
+ '/=>\s+([a-zA-Z])/im',
+ '/array\(\s+\)/im',
+ '/^ |\G /m',
+ ), array(
+ '=> $1',
+ 'array()',
+ ' ',
+ ), str_replace('array (', 'array(', var_export($value, true)));
+ $export .= PHP_EOL;
+ }
+ return str_replace('\\\\', '\\', $export);
}
/**