mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-05 04:37:38 +02:00
@@ -142,8 +142,12 @@ class NormalizerFormatter implements FormatterInterface
|
|||||||
$data['faultactor'] = $e->faultactor;
|
$data['faultactor'] = $e->faultactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($e->detail) && (is_string($e->detail) || is_object($e->detail) || is_array($e->detail))) {
|
if (isset($e->detail)) {
|
||||||
$data['detail'] = is_string($e->detail) ? $e->detail : reset($e->detail);
|
if (is_string($e->detail)) {
|
||||||
|
$data['detail'] = $e->detail;
|
||||||
|
} elseif (is_object($e->detail) || is_array($e->detail)) {
|
||||||
|
$data['detail'] = $this->toJson($e->detail, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,7 +92,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$formatter = new NormalizerFormatter('Y-m-d');
|
$formatter = new NormalizerFormatter('Y-m-d');
|
||||||
$e = new \SoapFault('foo', 'bar', 'hello', (object) array('foo' => 'world'));
|
$e = new \SoapFault('foo', 'bar', 'hello', 'world');
|
||||||
$formatted = $formatter->format(array(
|
$formatted = $formatter->format(array(
|
||||||
'exception' => $e,
|
'exception' => $e,
|
||||||
));
|
));
|
||||||
@@ -110,6 +110,26 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
'detail' => 'world',
|
'detail' => 'world',
|
||||||
),
|
),
|
||||||
), $formatted);
|
), $formatted);
|
||||||
|
|
||||||
|
$formatter = new NormalizerFormatter('Y-m-d');
|
||||||
|
$e = new \SoapFault('foo', 'bar', 'hello', (object) ['bar' => (object) ['biz' => 'baz'], 'foo' => 'world']);
|
||||||
|
$formatted = $formatter->format([
|
||||||
|
'exception' => $e,
|
||||||
|
]);
|
||||||
|
|
||||||
|
unset($formatted['exception']['trace']);
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'exception' => [
|
||||||
|
'class' => 'SoapFault',
|
||||||
|
'message' => 'bar',
|
||||||
|
'code' => 0,
|
||||||
|
'file' => $e->getFile().':'.$e->getLine(),
|
||||||
|
'faultcode' => 'foo',
|
||||||
|
'faultactor' => 'hello',
|
||||||
|
'detail' => '{"bar":{"biz":"baz"},"foo":"world"}',
|
||||||
|
],
|
||||||
|
], $formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatToStringExceptionHandle()
|
public function testFormatToStringExceptionHandle()
|
||||||
|
Reference in New Issue
Block a user