/** * Returns the configuration from $TYPO3_CONF_VARS['LOG'] as * hierarchical array for different components of the class hierarchy. * * @param string $configurationType Type of config to return (writer, processor) * @param string $loggerName Logger name * @throws \RangeException * @return array */ protected function getConfigurationForLogger($configurationType, $loggerName) { // Split up the logger name (dot-separated) into its parts $explodedName = explode('.', $loggerName); // Search in the $TYPO3_CONF_VARS['LOG'] array // for these keys, for example "writerConfiguration" $configurationKey = $configurationType . 'Configuration'; $configuration = $GLOBALS['TYPO3_CONF_VARS']['LOG']; $result = $configuration[$configurationKey] ?: array(); // Walk from general to special (t3lib, t3lib.db, t3lib.db.foo) // and search for the most specific configuration foreach ($explodedName as $partOfClassName) { if (!empty($configuration[$partOfClassName][$configurationKey])) { $result = $configuration[$partOfClassName][$configurationKey]; } $configuration = $configuration[$partOfClassName]; } // Validate the config foreach ($result as $level => $unused) { try { \TYPO3\CMS\Core\Log\LogLevel::validateLevel($level); } catch (\RangeException $e) { throw new \RangeException('The given severity level "' . htmlspecialchars($level) . '" for ' . $configurationKey . ' of logger "' . $loggerName . '" is not valid.', 1326406447); } } return $result; }
/** * Adds a log record. * * @param integer $level Log level. * @param string $message Log message. * @param array $data Additional data to log * @return mixed */ public function log($level, $message, array $data = array()) { \TYPO3\CMS\Core\Log\LogLevel::validateLevel($level); if ($level > $this->minimumLogLevel) { return $this; } /** @var $record \TYPO3\CMS\Core\Log\LogRecord */ $record = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogRecord', $this->name, $level, $message, $data); $record = $this->callProcessors($record); $this->writeLog($record); return $this; }
/** * @test * @dataProvider isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider * @expectedException \RangeException */ public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue) { \TYPO3\CMS\Core\Log\LogLevel::validateLevel($inputValue); }
/** * Sets the severity level * * @param integer $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) { \TYPO3\CMS\Core\Log\LogLevel::validateLevel($level); $this->level = $level; return $this; }
/** * @test * @dataprovider isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSoDataProvider */ public function isValidLevelThrowsExceptionOnInvalidLevelIfAskedToDoSo($inputValue) { $this->setExpectedException('RangeException'); \TYPO3\CMS\Core\Log\LogLevel::validateLevel($inputValue); }
/** * @param string $property * @return integer|NULL */ protected function setLogLevelThresholdByExtensionConfigurationProperty($property) { if (array_key_exists($property, $this->extensionConfiguration)) { LogLevel::validateLevel($this->extensionConfiguration[$property]); $this->{$property} = (int) $this->extensionConfiguration[$property]; } }
/** * Sets the severity level * * @param int $level Severity level * @return \TYPO3\CMS\Core\Log\LogRecord * @see \TYPO3\CMS\Core\Log\Level */ public function setLevel($level) { LogLevel::validateLevel($level); $this->level = $level; return $this; }