mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-08 06:06:40 +02:00
Merge pull request #2 from ZergMark/patch-1
Update to use more generic interfaces
This commit is contained in:
@@ -57,9 +57,9 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
{
|
{
|
||||||
if ($this->maxNestingLevel == 0 || $nestingLevel <= $this->maxNestingLevel) {
|
if ($this->maxNestingLevel == 0 || $nestingLevel <= $this->maxNestingLevel) {
|
||||||
foreach ($record as $name => $value) {
|
foreach ($record as $name => $value) {
|
||||||
if ($value instanceof \DateTime) {
|
if ($value instanceof \DateTimeInterface) {
|
||||||
$record[$name] = $this->formatDate($value, $nestingLevel + 1);
|
$record[$name] = $this->formatDate($value, $nestingLevel + 1);
|
||||||
} elseif ($value instanceof \Exception) {
|
} elseif ($value instanceof \Throwable) {
|
||||||
$record[$name] = $this->formatException($value, $nestingLevel + 1);
|
$record[$name] = $this->formatException($value, $nestingLevel + 1);
|
||||||
} elseif (is_array($value)) {
|
} elseif (is_array($value)) {
|
||||||
$record[$name] = $this->formatArray($value, $nestingLevel + 1);
|
$record[$name] = $this->formatArray($value, $nestingLevel + 1);
|
||||||
@@ -82,7 +82,7 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
return $this->formatArray($objectVars, $nestingLevel);
|
return $this->formatArray($objectVars, $nestingLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatException(\Exception $exception, $nestingLevel)
|
protected function formatException(\Throwable $exception, $nestingLevel)
|
||||||
{
|
{
|
||||||
$formattedException = array(
|
$formattedException = array(
|
||||||
'class' => get_class($exception),
|
'class' => get_class($exception),
|
||||||
@@ -100,7 +100,7 @@ class MongoDBFormatter implements FormatterInterface
|
|||||||
return $this->formatArray($formattedException, $nestingLevel);
|
return $this->formatArray($formattedException, $nestingLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function formatDate(\DateTime $value, $nestingLevel)
|
protected function formatDate(\DateTimeInterface $value, $nestingLevel)
|
||||||
{
|
{
|
||||||
$seconds = (int) $value->format('U');
|
$seconds = (int) $value->format('U');
|
||||||
$milliseconds = (int) $value->format('u') / 1000;
|
$milliseconds = (int) $value->format('u') / 1000;
|
||||||
|
Reference in New Issue
Block a user