diff --git a/composer.json b/composer.json index 0f4a0b9..bcaf204 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "phpstan/phpstan": "^1.4.10", "phpstan/phpstan-deprecation-rules": "^1.0.0", "phpstan/phpstan-phpunit": "^1.0.0", - "phpunit/phpunit": "^9.5.18", + "phpunit/phpunit": "^9.5.19", "predis/predis": "^1.1.10", "rollbar/rollbar": "^v2.1.0 || ^v3.1.1", "ruflin/elastica": "^7.1.4", diff --git a/src/Formatter/JsonFormatterFactory.php b/src/Formatter/JsonFormatterFactory.php index e7716ad..e076f52 100644 --- a/src/Formatter/JsonFormatterFactory.php +++ b/src/Formatter/JsonFormatterFactory.php @@ -15,6 +15,7 @@ use Interop\Container\ContainerInterface; use Laminas\ServiceManager\Factory\FactoryInterface; use Monolog\Formatter\JsonFormatter; +use Monolog\Formatter\NormalizerFormatter; use function array_key_exists; use function is_array; @@ -39,6 +40,8 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ $maxNormalizeDepth = NormalizerFormatterFactory::DEFAULT_NORMALIZER_DEPTH; $maxNormalizeItemCount = NormalizerFormatterFactory::DEFAULT_NORMALIZER_ITEM_COUNT; $prettyPrint = false; + $includeStacktraces = false; + $dateFormat = NormalizerFormatter::SIMPLE_DATE; if (is_array($options)) { if (array_key_exists('batchMode', $options)) { @@ -64,20 +67,19 @@ public function __invoke(ContainerInterface $container, $requestedName, ?array $ if (array_key_exists('prettyPrint', $options)) { $prettyPrint = $options['prettyPrint']; } - } - - $formatter = new JsonFormatter($batchMode, $appendNewline, $ignoreEmptyContextAndExtra); - if (is_array($options)) { if (array_key_exists('includeStacktraces', $options)) { - $formatter->includeStacktraces($options['includeStacktraces']); + $includeStacktraces = $options['includeStacktraces']; } if (array_key_exists('dateFormat', $options)) { - $formatter->setDateFormat($options['dateFormat']); + $dateFormat = $options['dateFormat']; } } + $formatter = new JsonFormatter($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces); + + $formatter->setDateFormat($dateFormat); $formatter->setMaxNormalizeDepth($maxNormalizeDepth); $formatter->setMaxNormalizeItemCount($maxNormalizeItemCount); $formatter->setJsonPrettyPrint($prettyPrint);