mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 21:56:31 +02:00
some cleanup
This commit is contained in:
@@ -28,7 +28,7 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
public function __construct($maxNestingLevel = 3, $exceptionTraceAsString = true)
|
public function __construct($maxNestingLevel = 3, $exceptionTraceAsString = true)
|
||||||
{
|
{
|
||||||
$this->maxNestingLevel = max($maxNestingLevel, 0);
|
$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)
|
protected function formatObject ($value, $nestingLevel)
|
||||||
{
|
{
|
||||||
$objectVars = get_object_vars($value);
|
$objectVars = get_object_vars($value);
|
||||||
$objectVars['class_name'] = get_class($value);
|
$objectVars['class'] = get_class($value);
|
||||||
return $this->formatArray($objectVars, $nestingLevel);
|
return $this->formatArray($objectVars, $nestingLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatException (\Exception $exception, $nestingLevel)
|
protected function formatException (\Exception $exception, $nestingLevel)
|
||||||
{
|
{
|
||||||
$formattedException = array(
|
$formattedException = array(
|
||||||
'class_name' => get_class($exception),
|
'class' => get_class($exception),
|
||||||
'message' => $exception->getMessage(),
|
'message' => $exception->getMessage(),
|
||||||
'code' => $exception->getCode(),
|
'code' => $exception->getCode(),
|
||||||
'file' => $exception->getFile(),
|
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
||||||
'line' => $exception->getLine(),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->exceptionTraceAsString === true) {
|
if ($this->exceptionTraceAsString === true) {
|
||||||
|
@@ -21,8 +21,6 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
return array(
|
return array(
|
||||||
array(1, true, 1, true),
|
array(1, true, 1, true),
|
||||||
array(0, false, 0, false),
|
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(
|
array(
|
||||||
'foo' => 'something',
|
'foo' => 'something',
|
||||||
'bar' => 'stuff',
|
'bar' => 'stuff',
|
||||||
'class_name' => 'stdClass',
|
'class' => 'stdClass',
|
||||||
),
|
),
|
||||||
$formattedRecord['context']['some_object']
|
$formattedRecord['context']['some_object']
|
||||||
);
|
);
|
||||||
@@ -118,7 +116,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertInternalType('string', $formattedRecord['context']['except']['file']);
|
$this->assertInternalType('string', $formattedRecord['context']['except']['file']);
|
||||||
$this->assertInternalType('integer', $formattedRecord['context']['except']['code']);
|
$this->assertInternalType('integer', $formattedRecord['context']['except']['code']);
|
||||||
$this->assertInternalType('string', $formattedRecord['context']['except']['trace']);
|
$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()
|
public function testFormatDepthArray()
|
||||||
@@ -224,7 +222,7 @@ class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase
|
|||||||
'nest2' => array(
|
'nest2' => array(
|
||||||
'property' => 'anything',
|
'property' => 'anything',
|
||||||
'nest3' => '[...]',
|
'nest3' => '[...]',
|
||||||
'class_name' => 'stdClass',
|
'class' => 'stdClass',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
$formattedResult['context']
|
$formattedResult['context']
|
||||||
|
Reference in New Issue
Block a user