From 04648dba784e52a79b9e03ca628743019e3e6009 Mon Sep 17 00:00:00 2001 From: Florian Plattner Date: Mon, 29 Dec 2014 20:38:08 +0100 Subject: [PATCH] some cleanup --- src/Monolog/Formatter/MongoDBFormatter.php | 9 ++++----- tests/Monolog/Formatter/MongoDBFormatterTest.php | 8 +++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Monolog/Formatter/MongoDBFormatter.php b/src/Monolog/Formatter/MongoDBFormatter.php index f1717d1f..538d79e4 100644 --- a/src/Monolog/Formatter/MongoDBFormatter.php +++ b/src/Monolog/Formatter/MongoDBFormatter.php @@ -28,7 +28,7 @@ class MongoDBFormatter implements FormatterInterface public function __construct($maxNestingLevel = 3, $exceptionTraceAsString = true) { $this->maxNestingLevel = max($maxNestingLevel, 0); - $this->exceptionTraceAsString = $exceptionTraceAsString == true && $exceptionTraceAsString !== 'false'; + $this->exceptionTraceAsString = (bool) $exceptionTraceAsString; } /** @@ -75,18 +75,17 @@ class MongoDBFormatter implements FormatterInterface protected function formatObject ($value, $nestingLevel) { $objectVars = get_object_vars($value); - $objectVars['class_name'] = get_class($value); + $objectVars['class'] = get_class($value); return $this->formatArray($objectVars, $nestingLevel); } protected function formatException (\Exception $exception, $nestingLevel) { $formattedException = array( - 'class_name' => get_class($exception), + 'class' => get_class($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode(), - 'file' => $exception->getFile(), - 'line' => $exception->getLine(), + 'file' => $exception->getFile() . ':' . $exception->getLine(), ); if ($this->exceptionTraceAsString === true) { diff --git a/tests/Monolog/Formatter/MongoDBFormatterTest.php b/tests/Monolog/Formatter/MongoDBFormatterTest.php index 95dcc876..389e54d5 100644 --- a/tests/Monolog/Formatter/MongoDBFormatterTest.php +++ b/tests/Monolog/Formatter/MongoDBFormatterTest.php @@ -21,8 +21,6 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase return array( array(1, true, 1, true), array(0, false, 0, false), - array(100000, 'true', 100000, true), - array(-1, 'false', 0, false) ); } @@ -105,7 +103,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase array( 'foo' => 'something', 'bar' => 'stuff', - 'class_name' => 'stdClass', + 'class' => 'stdClass', ), $formattedRecord['context']['some_object'] ); @@ -118,7 +116,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase $this->assertInternalType('string', $formattedRecord['context']['except']['file']); $this->assertInternalType('integer', $formattedRecord['context']['except']['code']); $this->assertInternalType('string', $formattedRecord['context']['except']['trace']); - $this->assertEquals('Exception', $formattedRecord['context']['except']['class_name']); + $this->assertEquals('Exception', $formattedRecord['context']['except']['class']); } public function testFormatDepthArray() @@ -224,7 +222,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase 'nest2' => array( 'property' => 'anything', 'nest3' => '[...]', - 'class_name' => 'stdClass', + 'class' => 'stdClass', ), ), $formattedResult['context']