[TASK] Streamline exceptions types in Logging API 75/28475/9
authorSteffen Müller <typo3@t3node.com>
Mon, 17 Mar 2014 15:54:18 +0000 (16:54 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sun, 7 Dec 2014 22:51:19 +0000 (23:51 +0100)
Resolves: #56998
Releases: master
Change-Id: I8fc06337e652b1778845be960f255f176725361a
Reviewed-on: http://review.typo3.org/28475
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
14 files changed:
typo3/sysext/core/Classes/Log/Exception.php [new file with mode: 0644]
typo3/sysext/core/Classes/Log/Exception/InvalidLogProcessorConfigurationException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Log/Exception/InvalidLogWriterConfigurationException.php [new file with mode: 0644]
typo3/sysext/core/Classes/Log/LogManager.php
typo3/sysext/core/Classes/Log/LogRecord.php
typo3/sysext/core/Classes/Log/Logger.php
typo3/sysext/core/Classes/Log/Processor/AbstractProcessor.php
typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Tests/Unit/Log/LogRecordTest.php
typo3/sysext/core/Tests/Unit/Log/LoggerTest.php
typo3/sysext/core/Tests/Unit/Log/Processor/AbstractProcessorTest.php
typo3/sysext/core/Tests/Unit/Log/Writer/AbstractWriterTest.php
typo3/sysext/core/Tests/Unit/Log/Writer/FileWriterTest.php

diff --git a/typo3/sysext/core/Classes/Log/Exception.php b/typo3/sysext/core/Classes/Log/Exception.php
new file mode 100644 (file)
index 0000000..5a3e01d
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace TYPO3\CMS\Core\Log;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * An exception when something is wrong with the file handling
+ */
+class Exception extends \TYPO3\CMS\Core\Exception {
+}
diff --git a/typo3/sysext/core/Classes/Log/Exception/InvalidLogProcessorConfigurationException.php b/typo3/sysext/core/Classes/Log/Exception/InvalidLogProcessorConfigurationException.php
new file mode 100644 (file)
index 0000000..4bc8ba3
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace TYPO3\CMS\Core\Log\Exception;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * An exception when something is wrong with the configuration for a LogProcessor
+ */
+class InvalidLogProcessorConfigurationException extends \TYPO3\CMS\Core\Log\Exception {
+}
diff --git a/typo3/sysext/core/Classes/Log/Exception/InvalidLogWriterConfigurationException.php b/typo3/sysext/core/Classes/Log/Exception/InvalidLogWriterConfigurationException.php
new file mode 100644 (file)
index 0000000..f98c4f4
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+namespace TYPO3\CMS\Core\Log\Exception;
+
+/**
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * An exception when something is wrong with the configuration for a LogWriter
+ */
+class InvalidLogWriterConfigurationException extends \TYPO3\CMS\Core\Log\Exception {
+}
index 764d15a..eaf44c6 100644 (file)
@@ -53,7 +53,7 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
         * Constructor
         */
        public function __construct() {
-               $this->rootLogger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\Logger::class, '');
+               $this->rootLogger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Logger::class, '');
                $this->loggers[''] = $this->rootLogger;
        }
 
@@ -89,7 +89,7 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
                } else {
                        // Lazy instantiation
                        /** @var $logger \TYPO3\CMS\Core\Log\Logger */
-                       $logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\Logger::class, $name);
+                       $logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Logger::class, $name);
                        $this->loggers[$name] = $logger;
                        $this->setWritersForLogger($logger);
                        $this->setProcessorsForLogger($logger);
@@ -121,7 +121,6 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
         *
         * @param \TYPO3\CMS\Core\Log\Logger $logger Logger to configure
         * @return void
-        * @throws \RangeException
         */
        protected function setWritersForLogger(Logger $logger) {
                $configuration = $this->getConfigurationForLogger(self::CONFIGURATION_TYPE_WRITER, $logger->getName());
@@ -132,7 +131,9 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
                                try {
                                        $logWriter = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($logWriterClassName, $logWriterOptions);
                                        $logger->addWriter($severityLevel, $logWriter);
-                               } catch (\RangeException $e) {
+                               } catch (\Psr\Log\InvalidArgumentException $e) {
+                                       $logger->warning('Instantiation of LogWriter "' . $logWriterClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
+                               } catch (\TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException $e) {
                                        $logger->warning('Instantiation of LogWriter "' . $logWriterClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
                                }
                        }
@@ -144,7 +145,6 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
         *
         * @param \TYPO3\CMS\Core\Log\Logger $logger Logger to configure
         * @return void
-        * @throws \RangeException
         */
        protected function setProcessorsForLogger(Logger $logger) {
                $configuration = $this->getConfigurationForLogger(self::CONFIGURATION_TYPE_PROCESSOR, $logger->getName());
@@ -155,7 +155,9 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
                                try {
                                        $logProcessor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($logProcessorClassName, $logProcessorOptions);
                                        $logger->addProcessor($severityLevel, $logProcessor);
-                               } catch (\RangeException $e) {
+                               } catch (\Psr\Log\InvalidArgumentException $e) {
+                                       $logger->warning('Instantiation of LogProcessor "' . $logProcessorClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
+                               } catch (\TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException $e) {
                                        $logger->warning('Instantiation of LogProcessor "' . $logProcessorClassName . '" failed for logger ' . $logger->getName() . ' (' . $e->getMessage() . ')');
                                }
                        }
@@ -168,7 +170,7 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
         *
         * @param string $configurationType Type of config to return (writer, processor)
         * @param string $loggerName Logger name
-        * @throws \RangeException
+        * @throws \Psr\Log\InvalidArgumentException
         * @return array
         */
        protected function getConfigurationForLogger($configurationType, $loggerName) {
@@ -191,8 +193,8 @@ class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterf
                foreach ($result as $level => $unused) {
                        try {
                                LogLevel::validateLevel($level);
-                       } catch (\RangeException $e) {
-                               throw new \RangeException('The given severity level "' . htmlspecialchars($level) . '" for ' . $configurationKey . ' of logger "' . $loggerName . '" is not valid.', 1326406447);
+                       } catch (\Psr\Log\InvalidArgumentException $e) {
+                               throw new \Psr\Log\InvalidArgumentException('The given severity level "' . htmlspecialchars($level) . '" for ' . $configurationKey . ' of logger "' . $loggerName . '" is not valid.', 1326406447);
                        }
                }
                return $result;
index 83e00d0..51365ce 100644 (file)
@@ -151,7 +151,6 @@ class LogRecord implements \ArrayAccess {
         *
         * @param int $level Severity level
         * @return \TYPO3\CMS\Core\Log\LogRecord
-        * @throws \RangeException if the given log level is invalid
         * @see \TYPO3\CMS\Core\Log\Level
         */
        public function setLevel($level) {
index 2477de5..b352549 100644 (file)
@@ -101,7 +101,7 @@ class Logger implements \Psr\Log\LoggerInterface {
         * @param \TYPO3\CMS\Core\Log\Writer\WriterInterface $writer Writer object
         * @return \TYPO3\CMS\Core\Log\Logger $this
         */
-       public function addWriter($minimumLevel, \TYPO3\CMS\Core\Log\Writer\WriterInterface $writer) {
+       public function addWriter($minimumLevel, Writer\WriterInterface $writer) {
                LogLevel::validateLevel($minimumLevel);
                // Cycle through all the log levels which are as severe as or higher
                // than $minimumLevel and add $writer to each severity level
@@ -133,7 +133,7 @@ class Logger implements \Psr\Log\LoggerInterface {
         * @param \TYPO3\CMS\Core\Log\Processor\ProcessorInterface $processor The processor to add.
         * @return void
         */
-       public function addProcessor($minimumLevel, \TYPO3\CMS\Core\Log\Processor\ProcessorInterface $processor) {
+       public function addProcessor($minimumLevel, Processor\ProcessorInterface $processor) {
                LogLevel::validateLevel($minimumLevel);
                // Cycle through all the log levels which are as severe as or higher
                // than $minimumLevel and add $processor to each severity level
@@ -172,7 +172,7 @@ class Logger implements \Psr\Log\LoggerInterface {
                        return $this;
                }
                /** @var $record \TYPO3\CMS\Core\Log\LogRecord */
-               $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogRecord::class, $this->name, $level, $message, $data);
+               $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(LogRecord::class, $this->name, $level, $message, $data);
                $record = $this->callProcessors($record);
                $this->writeLog($record);
                return $this;
index cc9371a..1756751 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Log\Processor;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException;
 
 /**
  * Abstract implementation of a log processor
@@ -25,7 +26,7 @@ abstract class AbstractProcessor implements ProcessorInterface {
         * Constructs this log processor
         *
         * @param array $options Configuration options - depends on the actual processor
-        * @throws \InvalidArgumentException
+        * @throws \TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException
         */
        public function __construct(array $options = array()) {
                foreach ($options as $optionKey => $optionValue) {
@@ -33,7 +34,7 @@ abstract class AbstractProcessor implements ProcessorInterface {
                        if (method_exists($this, $methodName)) {
                                $this->{$methodName}($optionValue);
                        } else {
-                               throw new \InvalidArgumentException('Invalid log processor option "' . $optionKey . '" for log processor of type "' . get_class($this) . '"', 1321696151);
+                               throw new InvalidLogProcessorConfigurationException('Invalid LogProcessor configuration option "' . $optionKey . '" for log processor of type "' . get_class($this) . '"', 1321696151);
                        }
                }
        }
index dff066c..c97eb2d 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Log\Writer;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException;
 
 /**
  * Abstract implementation of a log writer
@@ -25,7 +26,7 @@ abstract class AbstractWriter implements WriterInterface {
         * Constructs this log writer
         *
         * @param array $options Configuration options - depends on the actual log writer
-        * @throws \InvalidArgumentException
+        * @throws \TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException
         */
        public function __construct(array $options = array()) {
                foreach ($options as $optionKey => $optionValue) {
@@ -33,7 +34,7 @@ abstract class AbstractWriter implements WriterInterface {
                        if (method_exists($this, $methodName)) {
                                $this->{$methodName}($optionValue);
                        } else {
-                               throw new \InvalidArgumentException('Invalid log writer option "' . $optionKey . '" for log writer of type "' . get_class($this) . '"', 1321696152);
+                               throw new InvalidLogWriterConfigurationException('Invalid LogWriter configuration option "' . $optionKey . '" for log writer of type "' . get_class($this) . '"', 1321696152);
                        }
                }
        }
index af60bb3..b185184 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Log\Writer;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -76,14 +77,14 @@ class FileWriter extends AbstractWriter {
         *
         * @param string $logFile path to the log file, relative to PATH_site
         * @return \TYPO3\CMS\Core\Log\Writer\WriterInterface
-        * @throws \InvalidArgumentException
+        * @throws \TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException
         */
        public function setLogFile($logFile) {
 
                // Skip handling if logFile is a stream resource. This is used by unit tests with vfs:// directories
                if (FALSE === strpos($logFile, '://')) {
                        if (!GeneralUtility::isAllowedAbsPath((PATH_site . $logFile))) {
-                               throw new \InvalidArgumentException('Log file path "' . $logFile . '" is not valid!', 1326411176);
+                               throw new InvalidLogWriterConfigurationException('Log file path "' . $logFile . '" is not valid!', 1326411176);
                        }
                        $logFile = GeneralUtility::getFileAbsFileName($logFile);
                }
index 672a13a..3449727 100644 (file)
@@ -91,7 +91,7 @@ class LogRecordTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
-        * @expectedException Psr\Log\InvalidArgumentException
+        * @expectedException \Psr\Log\InvalidArgumentException
         */
        public function setLevelValidatesLevel() {
                $record = $this->getRecord();
index 66a106a..09919ed 100644 (file)
@@ -14,6 +14,12 @@ namespace TYPO3\CMS\Core\Tests\Unit\Log;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Log\Logger;
+use TYPO3\CMS\Core\Log\LogLevel;
+use TYPO3\CMS\Core\Log\LogRecord;
+use TYPO3\CMS\Core\Log\Processor\NullProcessor;
+use TYPO3\CMS\Core\Log\Writer\NullWriter;
+
 /**
  * Test case
  *
@@ -26,7 +32,7 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function getNameGetsLoggerName() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
+               $logger = new Logger('test.core.log');
                $this->assertSame('test.core.log', $logger->getName());
        }
 
@@ -34,11 +40,11 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function loggerDoesNotLogRecordsLessCriticalThanLogLevel() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::ERROR, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::ERROR, $writer);
                        // warning < error, thus must not be logged
-               $logger->log(\TYPO3\CMS\Core\Log\LogLevel::WARNING, 'test message');
+               $logger->log(LogLevel::WARNING, 'test message');
                $this->assertAttributeEmpty('records', $writer);
        }
 
@@ -46,31 +52,31 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function loggerReturnsItselfAfterLogging() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, $writer);
-               $returnValue = $logger->log(\TYPO3\CMS\Core\Log\LogLevel::WARNING, 'test message');
-               $this->assertInstanceOf(\TYPO3\CMS\Core\Log\Logger::class, $returnValue);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::DEBUG, $writer);
+               $returnValue = $logger->log(LogLevel::WARNING, 'test message');
+               $this->assertInstanceOf(Logger::class, $returnValue);
        }
 
        /**
         * @test
         */
        public function loggerReturnsItselfAfterLoggingWithoutWriter() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $returnValue = $logger->log(\TYPO3\CMS\Core\Log\LogLevel::WARNING, 'test message');
-               $this->assertInstanceOf(\TYPO3\CMS\Core\Log\Logger::class, $returnValue);
+               $logger = new Logger('test.core.log');
+               $returnValue = $logger->log(LogLevel::WARNING, 'test message');
+               $this->assertInstanceOf(Logger::class, $returnValue);
        }
 
        /**
         * @test
         */
        public function loggerReturnsItselfAfterLoggingLessCritical() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::EMERGENCY, $writer);
-               $returnValue = $logger->log(\TYPO3\CMS\Core\Log\LogLevel::WARNING, 'test message');
-               $this->assertInstanceOf(\TYPO3\CMS\Core\Log\Logger::class, $returnValue);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::EMERGENCY, $writer);
+               $returnValue = $logger->log(LogLevel::WARNING, 'test message');
+               $this->assertInstanceOf(Logger::class, $returnValue);
        }
 
        /**
@@ -78,15 +84,15 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function loggerCallsProcessor() {
                $component = 'test.core.log';
-               $level = \TYPO3\CMS\Core\Log\LogLevel::DEBUG;
+               $level = LogLevel::DEBUG;
                $message = 'test';
-               $logger = new \TYPO3\CMS\Core\Log\Logger($component);
-               /** @var $processor \TYPO3\CMS\Core\Log\Processor\ProcessorInterface */
-               $processor = $this->getMock(\TYPO3\CMS\Core\Log\Processor\NullProcessor::class, array('processLogRecord'));
-               $processor->expects($this->once())->method('processLogRecord')->will($this->returnValue(new \TYPO3\CMS\Core\Log\LogRecord($component, $level, $message)));
+               $logger = new Logger($component);
+               /** @var $processor \TYPO3\CMS\Core\Log\Processor\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject */
+               $processor = $this->getMock(NullProcessor::class, array('processLogRecord'));
+               $processor->expects($this->once())->method('processLogRecord')->will($this->returnValue(new LogRecord($component, $level, $message)));
                $logger->addProcessor($level, $processor);
                        // we need a writer, otherwise we will not process log records
-               $logger->addWriter($level, new \TYPO3\CMS\Core\Log\Writer\NullWriter());
+               $logger->addWriter($level, new NullWriter());
                $logger->warning($message);
        }
 
@@ -94,10 +100,11 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function loggerLogsRecord() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = $this->getMock(\TYPO3\CMS\Core\Log\Writer\NullWriter::class, array('writeLog'));
+               $logger = new Logger('test.core.log');
+               /** @var NullWriter|\PHPUnit_Framework_MockObject_MockObject $writer */
+               $writer = $this->getMock(NullWriter::class, array('writeLog'));
                $writer->expects($this->once())->method('writeLog');
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, $writer);
+               $logger->addWriter(LogLevel::DEBUG, $writer);
                $logger->warning('test');
        }
 
@@ -105,16 +112,16 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function loggerLogsRecordsAtLeastAsCriticalAsLogLevel() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::NOTICE, $writer);
                        // notice == notice, thus must be logged
-               $logger->log(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, 'test message');
+               $logger->log(LogLevel::NOTICE, 'test message');
                $this->assertAttributeNotEmpty('records', $writer);
        }
 
        /**
-        * @test
+        * @return array
         */
        public function loggerLogsRecordsThroughShorthandMethodDataProvider() {
                return array(
@@ -135,9 +142,9 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @dataProvider loggerLogsRecordsThroughShorthandMethodDataProvider
         */
        public function loggerLogsRecordsThroughShorthandMethod($shorthandMethod) {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::DEBUG, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::DEBUG, $writer);
                call_user_func(array($logger, $shorthandMethod), 'test message');
                $this->assertAttributeNotEmpty('records', $writer);
        }
@@ -146,11 +153,11 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function loggerLogsRecordsMoreCriticalThanLogLevel() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::NOTICE, $writer);
                        // warning > notice, thus must be logged
-               $logger->log(\TYPO3\CMS\Core\Log\LogLevel::WARNING, 'test message');
+               $logger->log(LogLevel::WARNING, 'test message');
                $this->assertAttributeNotEmpty('records', $writer);
        }
 
@@ -158,22 +165,22 @@ class LoggerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function addWriterAddsWriterToTheSpecifiedLevel() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::NOTICE, $writer);
                $writers = $logger->getWriters();
-               $this->assertContains($writer, $writers[\TYPO3\CMS\Core\Log\LogLevel::NOTICE]);
+               $this->assertContains($writer, $writers[LogLevel::NOTICE]);
        }
 
        /**
         * @test
         */
        public function addWriterAddsWriterAlsoToHigherLevelsThanSpecified() {
-               $logger = new \TYPO3\CMS\Core\Log\Logger('test.core.log');
-               $writer = new \TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture();
-               $logger->addWriter(\TYPO3\CMS\Core\Log\LogLevel::NOTICE, $writer);
+               $logger = new Logger('test.core.log');
+               $writer = new Fixtures\WriterFixture();
+               $logger->addWriter(LogLevel::NOTICE, $writer);
                $writers = $logger->getWriters();
-               $this->assertContains($writer, $writers[\TYPO3\CMS\Core\Log\LogLevel::EMERGENCY]);
+               $this->assertContains($writer, $writers[LogLevel::EMERGENCY]);
        }
 
 }
index c700d9e..c6c31be 100644 (file)
@@ -23,7 +23,7 @@ class AbstractProcessorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
-        * @expectedException \InvalidArgumentException
+        * @expectedException \TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException
         */
        public function processorRefusesInvalidConfigurationOptions() {
                $invalidConfiguration = array(
index 1099add..343e99a 100644 (file)
@@ -23,7 +23,7 @@ class AbstractWriterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
-        * @expectedException \InvalidArgumentException
+        * @expectedException \TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException
         */
        public function constructThrowsExceptionWithInvalidConfigurationOption() {
                $invalidConfiguration = array(
index 7015a36..33d61a5 100644 (file)
@@ -90,7 +90,7 @@ class FileWriterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
         * @test
-        * @expectedException \InvalidArgumentException
+        * @expectedException \TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException
         */
        public function setLogFileRefusesIllegalPath() {
                $writer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\Writer\FileWriter::class);