objectManager = $objectManager; $this->configurationManager = $configurationManager; } /** * Get a logger instance * The configuration of the logger is modified by extension typoscript config * * @param string $name the class name which this logger is for * @return \TYPO3\CMS\Core\Log\Logger */ public function getLogger(string $name): Logger { /** @var array $writerConfiguration */ $writerConfiguration = $GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration']; $settings = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'thRating', 'pi1' ); if (is_array($settings['logging'])) { foreach ($settings['logging'] as $logLevel => $logConfig) { $levelUppercase = strtoupper($logLevel); if (!empty($logConfig['file'])) { $writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::' . $levelUppercase)][FileWriter::class] = ['logFile' => $logConfig['file']]; } if (!empty($logConfig['database'])) { $writerConfiguration[constant('\TYPO3\CMS\Core\Log\LogLevel::' . $levelUppercase)][DatabaseWriter::class] = ['table' => $logConfig['table']]; } } } if (!empty($writerConfiguration)) { $GLOBALS['TYPO3_CONF_VARS']['LOG']['Thucke']['ThRating']['writerConfiguration'] = $writerConfiguration; } return $this->objectManager->get(LogManager::class)->getLogger($name); } }