Commit 27ee6450 authored by Markus Klein's avatar Markus Klein Committed by Benni Mack
Browse files

[!!!][TASK] Replace GeneralUtility::sysLog() with Logging API

The function GeneralUtility::sysLog() is deprecated and all calls
are replaced with direct calls to according Logging API methods.

The usual configuration options of the Logging API allows to
define all sorts of destinations for log entries, including
the syslog facility as well as file targets.

Resolves: #82430
Releases: master
Change-Id: Ief3f3f14fd10a3ae90b9df4a5e4e7456c2f7619c
Reviewed-on: https://review.typo3.org/54090


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarAlexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Tested-by: default avatarAlexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 5b1dff4c
......@@ -15,14 +15,18 @@ namespace TYPO3\CMS\Backend\Form;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Base class for container and single elements - their abstracts extend from here.
*/
abstract class AbstractNode implements NodeInterface
abstract class AbstractNode implements NodeInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Instance of the node factory to create sub elements, container and single element expansions.
*
......
......@@ -105,8 +105,7 @@ class FileThumbnails extends AbstractNode
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
$logMessage = $message . ' (' . $table . ':' . $row['uid'] . ')';
GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->warning($message, ['table' => $table, 'row' => $row]);
}
}
}
......
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Utility;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Cache\CacheManager;
......@@ -30,6 +31,7 @@ use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Imaging\ImageManipulation\CropVariantCollection;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Resource\AbstractFile;
use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
use TYPO3\CMS\Core\Resource\File;
......@@ -1245,8 +1247,7 @@ class BackendUtility
* The storage does not exist anymore
* Log the exception message for admins as they maybe can restore the storage
*/
$logMessage = $e->getMessage() . ' (table: "' . $tableName . '", fieldName: "' . $fieldName . '", referenceUid: ' . $referenceUid . ')';
GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
self::getLogger()->error($e->getMessage(), ['table' => $tableName, 'fieldName' => $fieldName, 'referenceUid' => $referenceUid, 'exception' => $e]);
}
}
......@@ -4469,6 +4470,14 @@ class BackendUtility
return GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
}
/**
* @return LoggerInterface
*/
protected static function getLogger()
{
return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
}
/**
* @return LanguageService
*/
......
......@@ -16,6 +16,8 @@ namespace TYPO3\CMS\Backend\View;
*/
use Doctrine\DBAL\Driver\Statement;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Backend\Controller\Page\LocalizationController;
use TYPO3\CMS\Backend\Controller\PageLayoutController;
......@@ -52,8 +54,10 @@ use TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList;
/**
* Child class for the Web > Page module
*/
class PageLayoutView
class PageLayoutView implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* If TRUE, users/groups are shown in the page info box.
*
......@@ -3871,11 +3875,7 @@ class PageLayoutView
}
}
} else {
GeneralUtility::sysLog(
sprintf('$TCA is broken for the table "%s": no required "columns" entry in $TCA.', $table),
'core',
GeneralUtility::SYSLOG_SEVERITY_ERROR
);
$this->logger->error('TCA is broken for the table "' . $table . '": no required "columns" entry in TCA.');
}
}
return $fieldListArr;
......
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Authentication;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Crypto\Random;
use TYPO3\CMS\Core\Database\Connection;
......@@ -42,8 +44,10 @@ use TYPO3\CMS\Core\Utility\MathUtility;
*
* See Inside TYPO3 for more information about the API of the class and internal variables.
*/
abstract class AbstractUserAuthentication
abstract class AbstractUserAuthentication implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Session/Cookie name
* @var string
......@@ -516,7 +520,7 @@ abstract class AbstractUserAuthentication
$match = [];
$matchCnt = @preg_match($cookieDomain, GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY'), $match);
if ($matchCnt === false) {
GeneralUtility::sysLog('The regular expression for the cookie domain (' . $cookieDomain . ') contains errors. The session is not shared across sub-domains.', 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
$this->logger->critical('The regular expression for the cookie domain (' . $cookieDomain . ') contains errors. The session is not shared across sub-domains.');
} elseif ($matchCnt) {
$result = $match[0];
}
......
......@@ -57,7 +57,7 @@ class AuthenticationService extends AbstractAuthenticationService
$this->writelog(255, 3, 3, 2, 'Login-attempt from %s (%s) for username \'%s\' with an empty password!', [
$this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']
]);
GeneralUtility::sysLog(sprintf('Login-attempt from %s (%s), for username \'%s\' with an empty password!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'Core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->warning(sprintf('Login-attempt from %s (%s), for username \'%s\' with an empty password!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
return false;
}
......@@ -65,8 +65,7 @@ class AuthenticationService extends AbstractAuthenticationService
if (!is_array($user)) {
// Failed login attempt (no username found)
$this->writelog(255, 3, 3, 2, 'Login-attempt from %s (%s), username \'%s\' not found!!', [$this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']]);
// Logout written to log
GeneralUtility::sysLog(sprintf('Login-attempt from %s (%s), username \'%s\' not found!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->warning(sprintf('Login-attempt from %s (%s), username \'%s\' not found!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
} else {
if ($this->writeDevLog) {
GeneralUtility::devLog('User found: ' . GeneralUtility::arrayToLogString($user, [$this->db_user['userid_column'], $this->db_user['username_column']]), self::class);
......@@ -100,7 +99,7 @@ class AuthenticationService extends AbstractAuthenticationService
// Failed login attempt (wrong password) - write that to the log!
if ($this->writeAttemptLog) {
$this->writelog(255, 3, 3, 1, 'Login-attempt from %s (%s), username \'%s\', password not accepted!', [$this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']]);
GeneralUtility::sysLog(sprintf('Login-attempt from %s (%s), username \'%s\', password not accepted!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->warning(sprintf('Login-attempt from %s (%s), username \'%s\', password not accepted!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
}
if ($this->writeDevLog) {
GeneralUtility::devLog('Password not accepted: ' . $this->login['uident'], self::class, 2);
......@@ -111,7 +110,7 @@ class AuthenticationService extends AbstractAuthenticationService
// Lock domain didn't match, so error:
if ($this->writeAttemptLog) {
$this->writelog(255, 3, 3, 1, 'Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!', [$this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']]);
GeneralUtility::sysLog(sprintf('Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']), 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->warning(sprintf('Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!', $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
}
$OK = 0;
}
......
......@@ -14,14 +14,19 @@ namespace TYPO3\CMS\Core\Cache\Backend;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
/**
* An abstract caching backend
*
* This file is a backport from FLOW3
* @api
*/
abstract class AbstractBackend implements \TYPO3\CMS\Core\Cache\Backend\BackendInterface
abstract class AbstractBackend implements BackendInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
const DATETIME_EXPIRYTIME_UNLIMITED = '9999-12-31T23:59:59+0000';
const UNLIMITED_LIFETIME = 0;
/**
......
......@@ -14,8 +14,6 @@ namespace TYPO3\CMS\Core\Cache\Backend;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* A caching backend which stores cache entries by using APC.
*
......@@ -146,8 +144,7 @@ class ApcBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend implement
$this->removeIdentifierFromAllTags($entryIdentifier);
$this->addIdentifierToTags($entryIdentifier, $tags);
} else {
$errorMessage = 'Error using APCu: Could not save data in the cache.';
GeneralUtility::sysLog($errorMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
$this->logger->alert('Error using APCu: Could not save data in the cache.');
}
}
......
......@@ -146,8 +146,7 @@ class ApcuBackend extends AbstractBackend implements TaggableBackendInterface
$this->removeIdentifierFromAllTags($entryIdentifier);
$this->addIdentifierToTags($entryIdentifier, $tags);
} else {
$errorMessage = 'Error using APCu: Could not save data in the cache.';
GeneralUtility::sysLog($errorMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
$this->logger->alert('Error using APCu: Could not save data in the cache.');
}
}
......
......@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Cache\Exception;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* A caching backend which stores cache entries by using Memcached.
......@@ -262,7 +261,7 @@ class MemcachedBackend extends AbstractBackend implements TaggableBackendInterfa
throw new Exception('Could not set data to memcache server.', 1275830266);
}
} catch (\Exception $exception) {
GeneralUtility::sysLog('Memcache: could not set value. Reason: ' . $exception->getMessage(), 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
$this->logger->alert('Memcache: could not set value.', ['exception' => $exception]);
}
}
......
......@@ -159,7 +159,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface
$this->connected = $this->redis->connect($this->hostname, $this->port, $this->connectionTimeout);
}
} catch (\Exception $e) {
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('Could not connect to redis server.', 'core', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
$this->logger->alert('Could not connect to redis server.', ['exception' => $e]);
}
if ($this->connected) {
if ($this->password !== '') {
......
......@@ -20,12 +20,16 @@ use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class Connection extends \Doctrine\DBAL\Connection
class Connection extends \Doctrine\DBAL\Connection implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Represents a SQL NULL data type.
*/
......@@ -397,11 +401,7 @@ class Connection extends \Doctrine\DBAL\Connection
foreach ($commandsToPerform as $command) {
if ($this->executeUpdate($command) === false) {
GeneralUtility::sysLog(
'Could not initialize DB connection with query "' . $command . '": ' . $this->errorInfo(),
'core',
GeneralUtility::SYSLOG_SEVERITY_ERROR
);
$this->logger->critical('Could not initialize DB connection with query "' . $command . '": ' . $this->errorInfo());
}
}
}
......
......@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Core\Database;
*/
use Doctrine\DBAL\DBALException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
......@@ -42,8 +44,10 @@ use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
* maintaining the index for workspace records. Or we can say that the index is precise for all Live elements while glitches might happen in an offline workspace?
* Anyway, I just wanted to document this finding - I don't think we can find a solution for it. And its very TemplaVoila specific.
*/
class ReferenceIndex
class ReferenceIndex implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Definition of tables to exclude from the ReferenceIndex
*
......@@ -1323,9 +1327,11 @@ class ReferenceIndex
->from($tableName)
->execute();
} catch (DBALException $e) {
// Table exists in $TCA but does not exist in the database
// @todo: improve / change message and add actual sql error?
GeneralUtility::sysLog(sprintf('Table "%s" exists in $TCA but does not exist in the database. You should run the Database Analyzer in the Install Tool to fix this.', $tableName), 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
// Table exists in TCA but does not exist in the database
$msg = 'Table "' .
$tableName .
'" exists in TCA but does not exist in the database. You should run the Database Analyzer in the Install Tool to fix this.';
$this->logger->error($msg, ['exception' => $e]);
continue;
}
......@@ -1349,14 +1355,7 @@ class ReferenceIndex
// Subselect based queries only work on the same connection
if ($refIndexConnectionName !== $tableConnectionName) {
GeneralUtility::sysLog(
sprintf(
'Not checking table "%s" for lost indexes, "sys_refindex" table uses a different connection',
$tableName
),
'core',
GeneralUtility::SYSLOG_SEVERITY_ERROR
);
$this->logger->error('Not checking table "' . $tableName . '" for lost indexes, "sys_refindex" table uses a different connection');
continue;
}
......
......@@ -14,7 +14,10 @@ namespace TYPO3\CMS\Core\Error;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -22,8 +25,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*
* This file is a backport from TYPO3 Flow
*/
abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, \TYPO3\CMS\Core\SingletonInterface
abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, SingletonInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
const CONTEXT_WEB = 'WEB';
const CONTEXT_CLI = 'CLI';
......@@ -50,7 +55,7 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, \T
*
* @param \Throwable $exception The throwable object.
* @param string $context The context where the exception was thrown, WEB or CLI
* @see \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(), \TYPO3\CMS\Core\Utility\GeneralUtility::devLog()
* @see \TYPO3\CMS\Core\Utility\GeneralUtility::devLog()
*/
protected function writeLogEntries(\Throwable $exception, $context)
{
......@@ -67,8 +72,7 @@ abstract class AbstractExceptionHandler implements ExceptionHandlerInterface, \T
$logMessage .= '. Requested URL: ' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
}
$backtrace = $exception->getTrace();
// Write error message to the configured syslogs
GeneralUtility::sysLog($logMessage, $logTitle, GeneralUtility::SYSLOG_SEVERITY_FATAL);
$this->logger->critical($logTitle . ': ' . $logMessage, ['exception' => $exception]);
// When database credentials are wrong, the exception is probably
// caused by this. Therefor we cannot do any database operation,
// otherwise this will lead into recurring exceptions.
......
......@@ -14,7 +14,10 @@ namespace TYPO3\CMS\Core\Error;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Log\LogLevel;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -23,8 +26,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*
* This file is a backport from TYPO3 Flow
*/
class ErrorHandler implements ErrorHandlerInterface
class ErrorHandler implements ErrorHandlerInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Error levels which should result in an exception thrown.
*
......@@ -120,11 +125,8 @@ class ErrorHandler implements ErrorHandlerInterface
}
$logTitle = 'Core: Error handler (' . TYPO3_MODE . ')';
$message = $logTitle . ': ' . $message;
// Write error message to the configured syslogs,
// see: $TYPO3_CONF_VARS['SYS']['systemLog']
if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['syslogErrorReporting']) {
GeneralUtility::sysLog($message, 'core', $severity + 1);
}
$this->logger->log(LogLevel::NOTICE - $severity, $message);
// Write error message to devlog extension(s),
GeneralUtility::devLog($message, 'core', $severity + 1);
......
......@@ -13,14 +13,20 @@ namespace TYPO3\CMS\Core\Service;
*
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Parent class for "Services" classes
*/
abstract class AbstractService
abstract class AbstractService implements LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var array service description array
*/
......@@ -259,7 +265,7 @@ abstract class AbstractService
$ret = true;
$progList = GeneralUtility::trimExplode(',', $progList, true);
foreach ($progList as $prog) {
if (!\TYPO3\CMS\Core\Utility\CommandUtility::checkCommand($prog)) {
if (!CommandUtility::checkCommand($prog)) {
// Program not found
$this->errorPush(T3_ERR_SV_PROG_NOT_FOUND, 'External program not found: ' . $prog);
$ret = false;
......@@ -273,7 +279,7 @@ abstract class AbstractService
*/
public function deactivateService()
{
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::deactivateService($this->info['serviceType'], $this->info['serviceKey']);
ExtensionManagementUtility::deactivateService($this->info['serviceType'], $this->info['serviceKey']);
}
/***************************************
......@@ -367,7 +373,7 @@ abstract class AbstractService
/**
* Register file which should be deleted afterwards.
*
* @param string File name with absolute path.
* @param string $absFile File name with absolute path.
*/
public function registerTempFile($absFile)
{
......
......@@ -15,10 +15,11 @@ namespace TYPO3\CMS\Core\Session\Backend;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Session\Backend\Exception\SessionNotCreatedException;
use TYPO3\CMS\Core\Session\Backend\Exception\SessionNotFoundException;
use TYPO3\CMS\Core\Session\Backend\Exception\SessionNotUpdatedException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class RedisSessionBackend
......@@ -26,8 +27,9 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* This session backend takes these optional configuration options: 'hostname' (default '127.0.0.1'),
* 'database' (default 0), 'port' (default 3679) and 'password' (no default value).
*/
class RedisSessionBackend implements SessionBackendInterface
class RedisSessionBackend implements SessionBackendInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var array
......@@ -249,11 +251,7 @@ class RedisSessionBackend implements SessionBackendInterface
$this->configuration['port'] ?? 6379
);
} catch (\RedisException $e) {
GeneralUtility::sysLog(
'Could not connect to redis server.',
'core',
GeneralUtility::SYSLOG_SEVERITY_ERROR
);
$this->logger->alert('Could not connect to redis server.', ['exception' => $e]);
}
if (!$this->connected) {
......
......@@ -14,8 +14,10 @@ namespace TYPO3\CMS\Core\TypoScript\Parser;
* The TYPO3 project - inspiring people to share!
*/
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher as BackendConditionMatcher;
use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -584,11 +586,7 @@ class TypoScriptParser
$fakeThis = false;
$newValue = GeneralUtility::callUserFunction($hookMethod, $params, $fakeThis);
} else {
GeneralUtility::sysLog(
'Missing function definition for ' . $modifierName . ' on TypoScript',
'core',
GeneralUtility::SYSLOG_SEVERITY_WARNING
);
$this->getLogger()->warning('Missing function definition for ' . $modifierName . ' on TypoScript');
}
}
return $newValue;
......@@ -790,7 +788,7 @@ class TypoScriptParser
{
$includedFiles = [];
if ($cycle_counter > 100) {
GeneralUtility::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags', 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
self::getLogger()->warning('It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags');
if ($returnFiles) {
return [
'typoscript' => '',
......@@ -1007,7 +1005,7 @@ class TypoScriptParser
/**
* Process errors in INCLUDE_TYPOSCRIPT tags
* Errors are logged in sysLog and printed in the concatenated Typoscript result (as can be seen in Template Analyzer)
* Errors are logged and printed in the concatenated TypoScript result (as can be seen in Template Analyzer)
*
* @param string $error Text of the error message
* @return string The error message encapsulated in comments
......@@ -1015,7 +1013,7 @@ class TypoScriptParser
*/
protected static function typoscriptIncludeError($error)
{
GeneralUtility::sysLog($error, 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
self::getLogger()->warning($error);
return "\n###\n### ERROR: " . $error . "\n###\n\n";
}
......@@ -1049,7 +1047,7 @@ class TypoScriptParser
public static function extractIncludes($string, $cycle_counter = 1, array $extractedFileNames = [], $parentFilenameOrPath = '')
{
if ($cycle_counter > 10) {
GeneralUtility::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags', 'core', GeneralUtility::SYSLOG_SEVERITY_WARNING);
self::getLogger()->warning('It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags');
return '
###
### ERROR: Recursion!
......@@ -1345,4 +1343,17 @@ class TypoScriptParser
{
return $this->modifyHTMLColor($color, $all, $all, $all);
}
/**
* Get a logger instance
*
* This class uses logging mostly in static functions, hence we need a static getter for the logger.
* Injection of a logger instance via GeneralUtility::makeInstance is not possible.
*
* @return LoggerInterface
*/
protected static function getLogger()
{
return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
}
}
......@@ -16,10 +16,12 @@ namespace TYPO3\CMS\Core\Utility;
use GuzzleHttp\Exception\RequestException;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Core\ApplicationContext;
use TYPO3\CMS\Core\Core\ClassLoadingInformation;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Log\LogLevel;