From af1076cbccbb847c7c0c99fe8ccd45d9466eaaa3 Mon Sep 17 00:00:00 2001 From: Jurj-Bogdan Date: Fri, 21 Feb 2025 12:55:34 +0200 Subject: [PATCH 1/4] issue77 Signed-off-by: Jurj-Bogdan --- src/Exception/InvalidArgumentException.php | 9 --------- src/Filter/Level.php | 2 +- src/Filter/Regex.php | 2 +- src/Filter/SuppressFilter.php | 2 +- src/Filter/Validator.php | 2 +- src/Formatter/Simple.php | 2 +- src/Logger.php | 2 +- src/LoggerServiceFactory.php | 2 +- src/Writer/AbstractWriter.php | 2 +- src/Writer/Stream.php | 2 +- test/Filter/LevelTest.php | 2 +- test/Filter/SuppressFilterTest.php | 2 +- test/Formatter/SimpleTest.php | 2 +- test/LoggerTest.php | 2 +- test/Writer/StreamTest.php | 2 +- 15 files changed, 14 insertions(+), 23 deletions(-) delete mode 100644 src/Exception/InvalidArgumentException.php diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php deleted file mode 100644 index bdc611f..0000000 --- a/src/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Fri, 21 Feb 2025 16:52:17 +0200 Subject: [PATCH 2/4] Revert "issue77" This reverts commit af1076cbccbb847c7c0c99fe8ccd45d9466eaaa3. --- src/Exception/InvalidArgumentException.php | 9 +++++++++ src/Filter/Level.php | 2 +- src/Filter/Regex.php | 2 +- src/Filter/SuppressFilter.php | 2 +- src/Filter/Validator.php | 2 +- src/Formatter/Simple.php | 2 +- src/Logger.php | 2 +- src/LoggerServiceFactory.php | 2 +- src/Writer/AbstractWriter.php | 2 +- src/Writer/Stream.php | 2 +- test/Filter/LevelTest.php | 2 +- test/Filter/SuppressFilterTest.php | 2 +- test/Formatter/SimpleTest.php | 2 +- test/LoggerTest.php | 2 +- test/Writer/StreamTest.php | 2 +- 15 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 src/Exception/InvalidArgumentException.php diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..bdc611f --- /dev/null +++ b/src/Exception/InvalidArgumentException.php @@ -0,0 +1,9 @@ + Date: Fri, 21 Feb 2025 16:55:00 +0200 Subject: [PATCH 3/4] change only log method Signed-off-by: Jurj-Bogdan --- src/Logger.php | 3 ++- test/LoggerTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Logger.php b/src/Logger.php index 3cb2380..a2e83f3 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -19,6 +19,7 @@ use Laminas\Stdlib\SplPriorityQueue; use Psr\Container\ContainerExceptionInterface; use Psr\Log\AbstractLogger; +use Psr\Log\InvalidArgumentException as PsrInvalidArgumentException; use Psr\Log\LogLevel; use Stringable; use Traversable; @@ -347,7 +348,7 @@ public function log(mixed $level, string|Stringable $message, iterable $context } if (($level < 0) || ($level >= count($this->levels))) { - throw new InvalidArgumentException(sprintf( + throw new PsrInvalidArgumentException(sprintf( '$level must be an integer >= 0 and < %d; received %s', count($this->levels), var_export($level, true) diff --git a/test/LoggerTest.php b/test/LoggerTest.php index 7e9bb12..f55cc82 100644 --- a/test/LoggerTest.php +++ b/test/LoggerTest.php @@ -5,7 +5,6 @@ namespace DotTest\Log; use ArrayObject; -use Dot\Log\Exception\InvalidArgumentException; use Dot\Log\Exception\RuntimeException; use Dot\Log\Logger; use Dot\Log\Manager\WriterPluginManager; @@ -19,6 +18,7 @@ use Laminas\Stdlib\SplPriorityQueue; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; +use Psr\Log\InvalidArgumentException; use function count; use function set_exception_handler; From 06ea45b0bc143d1f3eb7b2727e2aad41f6215b48 Mon Sep 17 00:00:00 2001 From: Jurj-Bogdan Date: Sat, 22 Feb 2025 18:23:14 +0200 Subject: [PATCH 4/4] requested changes Signed-off-by: Jurj-Bogdan --- src/Exception/InvalidArgumentException.php | 2 +- src/Logger.php | 3 +-- test/LoggerTest.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index bdc611f..e3fe7e0 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -4,6 +4,6 @@ namespace Dot\Log\Exception; -class InvalidArgumentException extends \InvalidArgumentException +class InvalidArgumentException extends \Psr\Log\InvalidArgumentException { } diff --git a/src/Logger.php b/src/Logger.php index a2e83f3..3cb2380 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -19,7 +19,6 @@ use Laminas\Stdlib\SplPriorityQueue; use Psr\Container\ContainerExceptionInterface; use Psr\Log\AbstractLogger; -use Psr\Log\InvalidArgumentException as PsrInvalidArgumentException; use Psr\Log\LogLevel; use Stringable; use Traversable; @@ -348,7 +347,7 @@ public function log(mixed $level, string|Stringable $message, iterable $context } if (($level < 0) || ($level >= count($this->levels))) { - throw new PsrInvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '$level must be an integer >= 0 and < %d; received %s', count($this->levels), var_export($level, true) diff --git a/test/LoggerTest.php b/test/LoggerTest.php index f55cc82..7e9bb12 100644 --- a/test/LoggerTest.php +++ b/test/LoggerTest.php @@ -5,6 +5,7 @@ namespace DotTest\Log; use ArrayObject; +use Dot\Log\Exception\InvalidArgumentException; use Dot\Log\Exception\RuntimeException; use Dot\Log\Logger; use Dot\Log\Manager\WriterPluginManager; @@ -18,7 +19,6 @@ use Laminas\Stdlib\SplPriorityQueue; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; -use Psr\Log\InvalidArgumentException; use function count; use function set_exception_handler;