[TASK] Throw InvalidArgumentException for undefined log level 47/21847/5
authorSteffen Müller <typo3@t3node.com>
Wed, 3 Jul 2013 13:53:00 +0000 (15:53 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 4 Jul 2013 14:40:57 +0000 (16:40 +0200)
PSR-3 expects Logger->log() to throw Psr\Log\InvalidArgumentException
when an invalid log level was given.

Resolves: #48876
Releases: 6.2
Change-Id: I89637e72acdce1b1a9e56b838b632d6b486dcae9
Reviewed-on: https://review.typo3.org/21847
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/contrib/Psr/Log/InvalidArgumentException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Log/LogLevel.php
typo3/sysext/core/Tests/Unit/Log/LogLevelTest.php
typo3/sysext/core/ext_autoload.php

diff --git a/typo3/contrib/Psr/Log/InvalidArgumentException.php b/typo3/contrib/Psr/Log/InvalidArgumentException.php
new file mode 100644 (file)
index 0000000..67f852d
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+namespace Psr\Log;
+
+class InvalidArgumentException extends \InvalidArgumentException
+{
+}
index 35c9147..7b03e6d 100644 (file)
@@ -139,11 +139,11 @@ class LogLevel {
         *
         * @param integer $level log level to validate
         * @return void
-        * @throws \RangeException if the given log level is invalid
+        * @throws \Psr\Log\InvalidArgumentException if the given log level is invalid
         */
        static public function validateLevel($level) {
                if (!self::isValidLevel($level)) {
-                       throw new \RangeException('Invalid Log Level.', 1321637121);
+                       throw new \Psr\Log\InvalidArgumentException('Invalid Log Level.', 1321637121);
                }
        }
 
index 08308e8..cfc2f16 100644 (file)
@@ -70,7 +70,7 @@ class LevelTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @test
         * @dataProvider isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider
-        * @expectedException \RangeException
+        * @expectedException \Psr\Log\InvalidArgumentException
         */
        public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue) {
                \TYPO3\CMS\Core\Log\LogLevel::validateLevel($inputValue);
index 5f55e92..556b9cf 100644 (file)
@@ -11,6 +11,7 @@ $typo3Classes = array(
        'tbe_pagetree' => PATH_typo3 . 'class.browse_links.php',
        'transferdata' => PATH_typo3 . 'show_item.php',
        'Psr\\Log\\LoggerInterface' => PATH_typo3 . 'contrib/Psr/Log/LoggerInterface.php',
+       'Psr\\Log\\InvalidArgumentException' => PATH_typo3 . 'contrib/Psr/Log/InvalidArgumentException.php',
 );
 return $typo3Classes;
 ?>
\ No newline at end of file