TYPO3 CMS  TYPO3_7-6
LogManagerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $logManagerInstance = null;
26 
27  protected function setUp()
28  {
29  $this->logManagerInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class);
30  }
31 
32  protected function tearDown()
33  {
34  \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->reset();
35  parent::tearDown();
36  }
37 
42  {
43  $this->assertInstanceOf(\TYPO3\CMS\Core\Log\Logger::class, $this->logManagerInstance->getLogger('test'));
44  }
45 
50  {
51  $this->assertSame('test.a.b', $this->logManagerInstance->getLogger('test_a_b')->getName());
52  }
53 
58  {
59  $this->assertSame('test.a.b', $this->logManagerInstance->getLogger('test\\a\\b')->getName());
60  }
61 
66  {
67  $loggerName = $this->getUniqueId('test.core.log');
68  $this->logManagerInstance->registerLogger($loggerName);
69  $logger1 = $this->logManagerInstance->getLogger($loggerName);
70  $logger2 = $this->logManagerInstance->getLogger($loggerName);
71  $this->assertSame($logger1, $logger2);
72  }
73 
77  public function configuresLoggerWithConfiguredWriter()
78  {
79  $component = 'test';
80  $writer = \TYPO3\CMS\Core\Log\Writer\NullWriter::class;
82  $GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['writerConfiguration'] = [
83  $level => [
84  $writer => []
85  ]
86  ];
88  $logger = $this->logManagerInstance->getLogger($component);
89  $writers = $logger->getWriters();
90  $this->assertInstanceOf($writer, $writers[$level][0]);
91  }
92 
96  public function configuresLoggerWithConfiguredProcessor()
97  {
98  $component = 'test';
99  $processor = \TYPO3\CMS\Core\Log\Processor\NullProcessor::class;
101  $GLOBALS['TYPO3_CONF_VARS']['LOG'][$component]['processorConfiguration'] = [
102  $level => [
103  $processor => []
104  ]
105  ];
107  $logger = $this->logManagerInstance->getLogger($component);
108  $processors = $logger->getProcessors();
109  $this->assertInstanceOf($processor, $processors[$level][0]);
110  }
111 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']