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

Add stack traces to normalized exceptions, closes #192

This commit is contained in:
Jordi Boggiano
2013-05-21 21:05:40 +02:00
parent e2b412846d
commit aa518ad791
2 changed files with 54 additions and 1 deletions

View File

@@ -28,7 +28,7 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
'context' => array(
'foo' => 'bar',
'baz' => 'qux',
)
),
));
$this->assertEquals(array(
@@ -49,6 +49,28 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
), $formatted);
}
public function testFormatExceptions()
{
$formatter = new NormalizerFormatter('Y-m-d');
$e = new \LogicException('bar');
$e2 = new \RuntimeException('foo', 0, $e);
$formatted = $formatter->format(array(
'exception' => $e2,
));
$this->assertGreaterThan(5, count($formatted['exception']['trace']));
$this->assertTrue(isset($formatted['exception']['previous']));
unset($formatted['exception']['trace'], $formatted['exception']['previous']);
$this->assertEquals(array(
'exception' => array(
'class' => get_class($e2),
'message' => $e2->getMessage(),
'file' => $e2->getFile().':'.$e2->getLine(),
)
), $formatted);
}
public function testBatchFormat()
{
$formatter = new NormalizerFormatter('Y-m-d');