Skip to content

Commit 6f3bb81

Browse files
committed
Merge branch 'master' of github.com:xp-framework/logging
2 parents 784b770 + b3d78b4 commit 6f3bb81

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/php/util/log/Layout.class.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php namespace util\log;
22

3-
use lang\{Generic, Value};
3+
use lang\Value;
44

55
/**
66
* Takes care of formatting log entries
77
*
8-
* @test xp://util.log.unittest.LayoutTest
8+
* @test util.log.unittest.LayoutTest
99
*/
1010
abstract class Layout {
1111

@@ -24,34 +24,34 @@ protected function stringOf($arg, $indent= '') {
2424
return 'true';
2525
} else if (is_string($arg)) {
2626
return '' === $indent ? $arg : '"'.$arg.'"';
27-
} else if ($arg instanceof Value || $arg instanceof Generic) {
27+
} else if ($arg instanceof Value) {
2828
return $arg->toString();
2929
} else if ([] === $arg) {
3030
return '[]';
3131
} else if (is_array($arg)) {
32-
$indent.= ' ';
3332
if (0 === key($arg)) {
3433
$r= '';
3534
foreach ($arg as $value) {
3635
$r.= ', '.$this->stringOf($value, $indent);
3736
}
3837
return '['.substr($r, 2).']';
3938
} else {
39+
$n= $indent.' ';
4040
$r= '[';
4141
foreach ($arg as $key => $value) {
42-
$r.= "\n".$indent.$key.' => '.$this->stringOf($value, $indent);
42+
$r.= "\n{$n}{$key} => ".$this->stringOf($value, $n);
4343
}
44-
return $r."\n]";
44+
return $r."\n{$indent}]";
4545
}
4646
} else if ($arg instanceof \Closure) {
4747
return $arg();
4848
} else if (is_object($arg)) {
49-
$indent.= ' ';
49+
$n= $indent.' ';
5050
$r= nameof($arg).'@{';
5151
foreach ((array)$arg as $key => $value) {
52-
$r.= "\n".$indent.$key.' => '.$this->stringOf($value, $indent);
52+
$r.= "\n{$n}{$key} => ".$this->stringOf($value, $n);
5353
}
54-
return $r."\n}";
54+
return $r."\n{$indent}}";
5555
} else {
5656
return (string)$arg;
5757
}

0 commit comments

Comments
 (0)