‪TYPO3CMS  9.5
LogManagerTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪LogManagerTest extends UnitTestCase
29 {
34  {
35  $this->assertInstanceOf(Logger::class, (new ‪LogManager())->getLogger('test'));
36  }
37 
42  {
43  $this->assertSame('test.a.b', (new ‪LogManager())->getLogger('test_a_b')->getName());
44  }
45 
50  {
51  $this->assertSame('test.a.b', (new ‪LogManager())->getLogger('test\\a\\b')->getName());
52  }
53 
58  {
59  $loggerName = $this->getUniqueId('test.core.log');
60  $logger = new ‪LogManager();
61  $logger->registerLogger($loggerName);
62  $logger1 = $logger->getLogger($loggerName);
63  $logger2 = $logger->getLogger($loggerName);
64  $this->assertSame($logger1, $logger2);
65  }
66 
71  {
72  $component = 'test';
73  $writer = NullWriter::class;
74  $level = ‪LogLevel::DEBUG;
75  ‪$GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['writerConfiguration'] = [
76  $level => [
77  $writer => []
78  ]
79  ];
80  $logger = (new ‪LogManager())->getLogger($component);
81  $writers = $logger->getWriters();
82  $this->assertInstanceOf($writer, $writers[$level][0]);
83  }
84 
89  {
90  $component = 'test';
91  $processor = NullProcessor::class;
92  $level = ‪LogLevel::DEBUG;
93  ‪$GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['processorConfiguration'] = [
94  $level => [
95  $processor => []
96  ]
97  ];
98  $logger = (new ‪LogManager())->getLogger($component);
99  $processors = $logger->getProcessors();
100  $this->assertInstanceOf($processor, $processors[$level][0]);
101  }
102 }
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\configuresLoggerWithConfiguredProcessor
‪configuresLoggerWithConfiguredProcessor()
Definition: LogManagerTest.php:88
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest
Definition: LogManagerTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerTurnsNamespaceStyleLoggerNamesIntoDotStyleLoggerNames
‪logManagerTurnsNamespaceStyleLoggerNamesIntoDotStyleLoggerNames()
Definition: LogManagerTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\configuresLoggerWithConfiguredWriter
‪configuresLoggerWithConfiguredWriter()
Definition: LogManagerTest.php:70
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerReturnsLoggerWhenRequestedWithGetLogger
‪logManagerReturnsLoggerWhenRequestedWithGetLogger()
Definition: LogManagerTest.php:33
‪TYPO3\CMS\Core\Tests\Unit\Log
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\managerReturnsSameLoggerOnRepeatedRequest
‪managerReturnsSameLoggerOnRepeatedRequest()
Definition: LogManagerTest.php:57
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerTurnsUnderScoreStyleLoggerNamesIntoDotStyleLoggerNames
‪logManagerTurnsUnderScoreStyleLoggerNamesIntoDotStyleLoggerNames()
Definition: LogManagerTest.php:41
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:25
‪TYPO3\CMS\Core\Log\Logger
Definition: Logger.php:23
‪TYPO3\CMS\Core\Log\Writer\NullWriter
Definition: NullWriter.php:22
‪TYPO3\CMS\Core\Log\LogLevel\DEBUG
‪const DEBUG
Definition: LogLevel.php:94
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:21
‪TYPO3\CMS\Core\Log\Processor\NullProcessor
Definition: NullProcessor.php:21