From 1e19c65b67a504e9e97ae4801be1058116a89c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 6 Sep 2019 15:00:06 +0200 Subject: [PATCH] [MonologBridge] Bump min version for monolog ^1.25 and drop dead code --- composer.json | 2 +- .../Handler/ElasticsearchLogstashHandler.php | 2 + .../Handler/FormattableHandlerTrait.php | 73 ------------------ .../Handler/ProcessableHandlerTrait.php | 74 ------------------- src/Symfony/Bridge/Monolog/composer.json | 2 +- 5 files changed, 4 insertions(+), 149 deletions(-) delete mode 100644 src/Symfony/Bridge/Monolog/Handler/FormattableHandlerTrait.php delete mode 100644 src/Symfony/Bridge/Monolog/Handler/ProcessableHandlerTrait.php diff --git a/composer.json b/composer.json index a22d9e240e3c..d9d12048307f 100644 --- a/composer.json +++ b/composer.json @@ -109,7 +109,7 @@ "doctrine/reflection": "~1.0", "doctrine/doctrine-bundle": "~1.4", "masterminds/html5": "^2.6", - "monolog/monolog": "~1.11", + "monolog/monolog": "^1.25.1", "nyholm/psr7": "^1.0", "ocramius/proxy-manager": "^2.1", "php-http/httplug": "^1.0|^2.0", diff --git a/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php b/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php index 2f4d9286c5c0..458472c6e0cb 100644 --- a/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php +++ b/src/Symfony/Bridge/Monolog/Handler/ElasticsearchLogstashHandler.php @@ -14,6 +14,8 @@ use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\LogstashFormatter; use Monolog\Handler\AbstractHandler; +use Monolog\Handler\FormattableHandlerTrait; +use Monolog\Handler\ProcessableHandlerTrait; use Monolog\Logger; use Symfony\Component\HttpClient\HttpClient; use Symfony\Contracts\HttpClient\Exception\ExceptionInterface; diff --git a/src/Symfony/Bridge/Monolog/Handler/FormattableHandlerTrait.php b/src/Symfony/Bridge/Monolog/Handler/FormattableHandlerTrait.php deleted file mode 100644 index c03bc7556a68..000000000000 --- a/src/Symfony/Bridge/Monolog/Handler/FormattableHandlerTrait.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/* - * This file is part of the Monolog package. - * - * (c) Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; -use Monolog\Formatter\LineFormatter; - -/** - * Helper trait for implementing FormattableInterface. - * - * @author Jordi Boggiano - * - * @internal - */ -trait FormattableHandlerTrait -{ - /** - * @var FormatterInterface - */ - protected $formatter; - - /** - * {@inheritdoc} - * - * @suppress PhanTypeMismatchReturn - */ - public function setFormatter(FormatterInterface $formatter): HandlerInterface - { - $this->formatter = $formatter; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getFormatter(): FormatterInterface - { - if (!$this->formatter) { - $this->formatter = $this->getDefaultFormatter(); - } - - return $this->formatter; - } - - /** - * Gets the default formatter. - * - * Overwrite this if the LineFormatter is not a good default for your handler. - */ - protected function getDefaultFormatter(): FormatterInterface - { - return new LineFormatter(); - } -} diff --git a/src/Symfony/Bridge/Monolog/Handler/ProcessableHandlerTrait.php b/src/Symfony/Bridge/Monolog/Handler/ProcessableHandlerTrait.php deleted file mode 100644 index 9c80d3318c32..000000000000 --- a/src/Symfony/Bridge/Monolog/Handler/ProcessableHandlerTrait.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bridge\Monolog\Handler; - -use Monolog\ResettableInterface; - -/** - * Helper trait for implementing ProcessableInterface. - * - * @author Jordi Boggiano - * - * @internal - */ -trait ProcessableHandlerTrait -{ - /** - * @var callable[] - */ - protected $processors = []; - - /** - * {@inheritdoc} - * - * @suppress PhanTypeMismatchReturn - */ - public function pushProcessor($callback): HandlerInterface - { - array_unshift($this->processors, $callback); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function popProcessor(): callable - { - if (!$this->processors) { - throw new \LogicException('You tried to pop from an empty processor stack.'); - } - - return array_shift($this->processors); - } - - /** - * Processes a record. - */ - protected function processRecord(array $record): array - { - foreach ($this->processors as $processor) { - $record = $processor($record); - } - - return $record; - } - - protected function resetProcessors() - { - foreach ($this->processors as $processor) { - if ($processor instanceof ResettableInterface) { - $processor->reset(); - } - } - } -} diff --git a/src/Symfony/Bridge/Monolog/composer.json b/src/Symfony/Bridge/Monolog/composer.json index f5b607edd8c9..f2b34f6c9bed 100644 --- a/src/Symfony/Bridge/Monolog/composer.json +++ b/src/Symfony/Bridge/Monolog/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": "^7.1.3", - "monolog/monolog": "~1.19", + "monolog/monolog": "^1.25.1", "symfony/service-contracts": "^1.1", "symfony/http-kernel": "^4.3" },