‪TYPO3CMS  10.4
LogManagerTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪LogManagerTest extends UnitTestCase
32 {
37  {
38  self::assertInstanceOf(Logger::class, (new ‪LogManager())->getLogger('test'));
39  }
40 
45  {
46  self::assertSame('test.a.b', (new ‪LogManager())->getLogger('test_a_b')->getName());
47  }
48 
53  {
54  self::assertSame('test.a.b', (new ‪LogManager())->getLogger('test\\a\\b')->getName());
55  }
56 
61  {
62  $loggerName = ‪StringUtility::getUniqueId('test.core.log');
63  $logger = new ‪LogManager();
64  $logger->registerLogger($loggerName);
65  $logger1 = $logger->getLogger($loggerName);
66  $logger2 = $logger->getLogger($loggerName);
67  self::assertSame($logger1, $logger2);
68  }
69 
74  {
75  $component = 'test';
76  $writer = NullWriter::class;
77  $level = LogLevel::DEBUG;
78  ‪$GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['writerConfiguration'] = [
79  $level => [
80  $writer => []
81  ]
82  ];
83  $logger = (new ‪LogManager())->getLogger($component);
84  $writers = $logger->getWriters();
85  self::assertInstanceOf($writer, $writers[$level][0]);
86  }
87 
92  {
93  $component = 'test';
94  $processor = NullProcessor::class;
95  $level = LogLevel::DEBUG;
96  ‪$GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['processorConfiguration'] = [
97  $level => [
98  $processor => []
99  ]
100  ];
101  $logger = (new ‪LogManager())->getLogger($component);
102  $processors = $logger->getProcessors();
103  self::assertInstanceOf($processor, $processors[$level][0]);
104  }
105 }
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\configuresLoggerWithConfiguredProcessor
‪configuresLoggerWithConfiguredProcessor()
Definition: LogManagerTest.php:91
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest
Definition: LogManagerTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerTurnsNamespaceStyleLoggerNamesIntoDotStyleLoggerNames
‪logManagerTurnsNamespaceStyleLoggerNamesIntoDotStyleLoggerNames()
Definition: LogManagerTest.php:52
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\configuresLoggerWithConfiguredWriter
‪configuresLoggerWithConfiguredWriter()
Definition: LogManagerTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerReturnsLoggerWhenRequestedWithGetLogger
‪logManagerReturnsLoggerWhenRequestedWithGetLogger()
Definition: LogManagerTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Log
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\managerReturnsSameLoggerOnRepeatedRequest
‪managerReturnsSameLoggerOnRepeatedRequest()
Definition: LogManagerTest.php:60
‪TYPO3\CMS\Core\Tests\Unit\Log\LogManagerTest\logManagerTurnsUnderScoreStyleLoggerNamesIntoDotStyleLoggerNames
‪logManagerTurnsUnderScoreStyleLoggerNamesIntoDotStyleLoggerNames()
Definition: LogManagerTest.php:44
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Log\LogManager
Definition: LogManager.php:30
‪TYPO3\CMS\Core\Log\Logger
Definition: Logger.php:27
‪TYPO3\CMS\Core\Log\Writer\NullWriter
Definition: NullWriter.php:24
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:24
‪TYPO3\CMS\Core\Log\Processor\NullProcessor
Definition: NullProcessor.php:24