[!!!][TASK] Replace GeneralUtility::sysLog() with Logging API 90/54090/8
authorMarkus Klein <markus.klein@typo3.org>
Sat, 9 Sep 2017 23:49:27 +0000 (01:49 +0200)
committerBenni Mack <benni@typo3.org>
Mon, 18 Sep 2017 06:40:32 +0000 (08:40 +0200)
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: TYPO3com <no-reply@typo3.com>
Reviewed-by: Alexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Tested-by: Alexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
36 files changed:
typo3/sysext/backend/Classes/Form/AbstractNode.php
typo3/sysext/backend/Classes/Form/FieldWizard/FileThumbnails.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/Authentication/AuthenticationService.php
typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php
typo3/sysext/core/Classes/Cache/Backend/ApcBackend.php
typo3/sysext/core/Classes/Cache/Backend/ApcuBackend.php
typo3/sysext/core/Classes/Cache/Backend/MemcachedBackend.php
typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php
typo3/sysext/core/Classes/Database/Connection.php
typo3/sysext/core/Classes/Database/ReferenceIndex.php
typo3/sysext/core/Classes/Error/AbstractExceptionHandler.php
typo3/sysext/core/Classes/Error/ErrorHandler.php
typo3/sysext/core/Classes/Service/AbstractService.php
typo3/sysext/core/Classes/Session/Backend/RedisSessionBackend.php
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Configuration/DefaultConfigurationDescription.yaml
typo3/sysext/core/Documentation/Changelog/master/Breaking-82430-ReplacedGeneralUtilitysysLogWithLoggingAPI.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-82430-GeneralUtilitysysLog.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/extbase/Classes/Scheduler/Task.php
typo3/sysext/felogin/Classes/Controller/FrontendLoginController.php
typo3/sysext/felogin/Resources/Private/Language/locallang.xlf
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Page/PageRepository.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
typo3/sysext/saltedpasswords/Classes/SaltedPasswordService.php
typo3/sysext/scheduler/Classes/Task/AbstractTask.php
typo3/sysext/workspaces/Classes/Service/GridDataService.php

index 8081b81..67bea6c 100644 (file)
@@ -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.
      *
index c957fab..9836693 100644 (file)
@@ -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]);
                 }
             }
         }
index 46af96a..960d820 100644 (file)
@@ -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]);
             }
         }
 
@@ -4470,6 +4471,14 @@ class BackendUtility
     }
 
     /**
+     * @return LoggerInterface
+     */
+    protected static function getLogger()
+    {
+        return GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
+    }
+
+    /**
      * @return LanguageService
      */
     protected static function getLanguageService()
index 54b3e93..05bd1f3 100644 (file)
@@ -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;
index 34b0e3f..ab814d8 100644 (file)
@@ -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];
                 }
index f330719..2eadf12 100644 (file)
@@ -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;
             }
index 6ef1d02..182ab2e 100644 (file)
@@ -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;
     /**
index 508873c..67a4557 100644 (file)
@@ -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.');
         }
     }
 
index b9eb0c0..f040447 100644 (file)
@@ -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.');
         }
     }
 
index 803bc18..317165b 100644 (file)
@@ -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]);
         }
     }
 
index 32dfc73..bfe4fd0 100644 (file)
@@ -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 !== '') {
index 531f841..de7aead 100644 (file)
@@ -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());
             }
         }
     }
index 39c5a68..01b3c0d 100644 (file)
@@ -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;
             }
 
index d61ae88..e5f2b6f 100644 (file)
@@ -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.
index 41d646e..2bd87a3 100644 (file)
@@ -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);
 
index 1ccd225..a03934f 100644 (file)
@@ -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)
     {
index 87ded7b..36feae1 100644 (file)
@@ -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) {
index 00c3255..8787970 100644 (file)
@@ -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__);
+    }
 }
index b87b51b..c09a25d 100644 (file)
@@ -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;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\SingletonInterface;
@@ -39,7 +41,7 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  */
 class GeneralUtility
 {
-    // Severity constants used by \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog()
+    // Severity constants used by \TYPO3\CMS\Core\Utility\GeneralUtility::devLog()
     const SYSLOG_SEVERITY_INFO = 0;
     const SYSLOG_SEVERITY_NOTICE = 1;
     const SYSLOG_SEVERITY_WARNING = 2;
@@ -3167,7 +3169,7 @@ class GeneralUtility
             }
         }
         if (!empty($url) && empty($sanitizedUrl)) {
-            self::sysLog('The URL "' . $url . '" is not considered to be local and was denied.', 'core', self::SYSLOG_SEVERITY_NOTICE);
+            static::getLogger()->notice('The URL "' . $url . '" is not considered to be local and was denied.');
         }
         return $sanitizedUrl;
     }
@@ -3795,15 +3797,10 @@ class GeneralUtility
      * Initialize the system log.
      *
      * @see sysLog()
+     * @deprecated since TYPO3 v9, will be removed in TYPO3 v10
      */
     public static function initSysLog()
     {
-        // For CLI logging name is <fqdn-hostname>:<TYPO3-path>
-        if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI) {
-            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getHostname() . ':' . PATH_site;
-        } else {
-            $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getIndpEnv('TYPO3_SITE_URL');
-        }
         // Init custom logging
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
             $params = ['initLog' => true];
@@ -3812,34 +3809,26 @@ class GeneralUtility
                 self::callUserFunction($hookMethod, $params, $fakeThis);
             }
         }
-        // Init TYPO3 logging
-        foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) {
-            list($type, $destination) = explode(',', $log, 3);
-            if ($type === 'syslog') {
-                if (TYPO3_OS === 'WIN') {
-                    $facility = LOG_USER;
-                } else {
-                    $facility = constant('LOG_' . strtoupper($destination));
-                }
-                openlog($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
-            }
-        }
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'], 0, 4);
         $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = true;
     }
 
     /**
-     * Logs message to the system log.
+     * Logs message to custom "systemLog" handlers and logging API
+     *
      * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
      * If you want to implement the sysLog in your applications, simply add lines like:
      * \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('[write message in English here]', 'extension_key', 'severity');
      *
      * @param string $msg Message (in English).
-     * @param string $extKey Extension key (from which extension you are calling the log) or "Core
+     * @param string $extKey Extension key (from which extension you are calling the log) or "Core"
      * @param int $severity \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_* constant
+     * @deprecated since TYPO3 v9, will be removed in TYPO3 v10
      */
     public static function sysLog($msg, $extKey, $severity = 0)
     {
+        static::logDeprecatedFunction();
+
         $severity = MathUtility::forceIntegerInRange($severity, 0, 4);
         // Is message worth logging?
         if ((int)$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] > $severity) {
@@ -3861,40 +3850,8 @@ class GeneralUtility
         if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']) {
             return;
         }
-        $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
-        $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
-        // Use all configured logging options
-        foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) {
-            list($type, $destination, $level) = explode(',', $log, 4);
-            // Is message worth logging for this log type?
-            if ((int)$level > $severity) {
-                continue;
-            }
-            $msgLine = ' - ' . $extKey . ': ' . $msg;
-            // Write message to a file
-            if ($type === 'file') {
-                $file = fopen($destination, 'a');
-                if ($file) {
-                    fwrite($file, date(($dateFormat . ' ' . $timeFormat)) . $msgLine . LF);
-                    fclose($file);
-                    self::fixPermissions($destination);
-                }
-            } elseif ($type === 'mail') {
-                list($to, $from) = explode('/', $destination);
-                if (!self::validEmail($from)) {
-                    $from = MailUtility::getSystemFrom();
-                }
-                /** @var $mail \TYPO3\CMS\Core\Mail\MailMessage */
-                $mail = self::makeInstance(\TYPO3\CMS\Core\Mail\MailMessage::class);
-                $mail->setTo($to)->setFrom($from)->setSubject('Warning - error in TYPO3 installation')->setBody('Host: ' . $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . LF . 'Extension: ' . $extKey . LF . 'Severity: ' . $severity . LF . LF . $msg);
-                $mail->send();
-            } elseif ($type === 'error_log') {
-                error_log($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
-            } elseif ($type === 'syslog') {
-                $priority = [LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT];
-                syslog($priority[(int)$severity], $msgLine);
-            }
-        }
+
+        static::getLogger()->log(LogLevel::INFO - $severity, $msg, ['extension' => $extKey]);
     }
 
     /**
@@ -4154,4 +4111,12 @@ class GeneralUtility
     {
         return in_array(PHP_SAPI, self::$supportedCgiServerApis, true);
     }
+
+    /**
+     * @return LoggerInterface
+     */
+    protected static function getLogger()
+    {
+        return static::makeInstance(LogManager::class)->getLogger(__CLASS__);
+    }
 }
index 37eae4f..7842692 100644 (file)
@@ -90,7 +90,7 @@ return [
         'setDBinit' => '',
         'setMemoryLimit' => 0,
         'phpTimeZone' => '',
-        'systemLog' => '',
+        'systemLog' => false,
         'systemLogLevel' => 0,
         'enableDeprecationLog' => '',
         'UTF8filesystem' => false,
@@ -217,7 +217,6 @@ return [
         'errorHandler' => \TYPO3\CMS\Core\Error\ErrorHandler::class,
         'errorHandlerErrors' => E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR),
         'exceptionalErrors' => E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING),
-        'syslogErrorReporting' => E_ALL & ~(E_STRICT | E_NOTICE),
         'belogErrorReporting' => E_ALL & ~(E_STRICT | E_NOTICE),
         'locallangXMLOverride' => [], // For extension/overriding of the arrays in 'locallang' files in frontend  and backend. See 'Inside TYPO3' for more information.
         'generateApacheHtaccess' => 1,
index f5258db..bfbda91 100644 (file)
@@ -145,8 +145,8 @@ SYS:
             type: text
             description: 'timezone to force for all date() and mktime() functions. A list of supported values can be found at <a href="http://php.net/manual/en/timezones.php" target="_blank">php.net</a>. If this is not set, a valid fallback will be searched for by PHP (php.ini''s <a href="http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone" target="_blank">date.timezone</a> setting, server defaults, etc); and if no fallback is found, the value of "UTC" is used instead.'
         systemLog:
-            type: list
-            description: '<p>semi-colon separated list. Defines one or more logging methods. Possible methods:</p><dl><dt>file,&lt;abs-path-to-file&gt;[,&lt;level&gt;]</dt><dd>logs to a file</dd><dt>mail,&lt;to&gt;[/&lt;from&gt;][,&lt;level&gt;]</dt><dd>sends the log entries via mail</dd><dt>syslog,&lt;facility&gt;,[,&lt;level&gt;]</dt><dd>uses the operating system''s log. Facility may be one of LOCAL0..LOCAL7, USER (on Windows USER is the only valid type).</dd><dt>error_log[,,&lt;level&gt;]</dt><dd>uses the PHP error log</dd></dl><p>The &lt;level&gt; is the individual logging level (see <a href="#SYS-systemLogLevel">[SYS][systemLogLevel]</a>).</p>'
+            type: bool
+            description: 'Enables the deprecated system log functionality. Log data is written the to the Logging API.'
         systemLogLevel:
             type: int
             allowedValues:
@@ -202,19 +202,16 @@ SYS:
             description: 'Classname to handle exceptions that might happen in the TYPO3-code. Leave empty to disable exception handling. Default: "TYPO3\CMS\Core\Error\DebugExceptionHandler". This exception handler displays the complete stack trace of any encountered exception. The error message and the stack trace is logged to the configured logs. Note: The configured "debugExceptionHandler" is used if [SYS][displayErrors] is set to "1" or is set to "-1" or "2" and the [SYS][devIPmask] matches the user''s IP.'
         errorHandler:
             type: phpClass
-            description: 'Classname to handle PHP errors. E.g.: TYPO3\CMS\Core\Error\ErrorHandler. This class displays and logs all errors that are registered as [SYS][errorHandlerErrors]. Leave empty to disable error handling. Errors can be logged to syslog (see: [SYS][systemLog]), to the installed developer log and to the "syslog" table. If an error is registered in [SYS][exceptionalErrors] it will be turned into an exception to be handled by the configured exceptionHandler.'
+            description: 'Classname to handle PHP errors. E.g.: TYPO3\CMS\Core\Error\ErrorHandler. This class displays and logs all errors that are registered as [SYS][errorHandlerErrors]. Leave empty to disable error handling. Errors will be logged and can be sent to the optionally installed developer log or to the "syslog" database table. If an error is registered in [SYS][exceptionalErrors] it will be turned into an exception to be handled by the configured exceptionHandler.'
         errorHandlerErrors:
             type: errors
             description: 'The E_* constant that will be handled by the [SYS][errorHandler]. Not all PHP error types can be handled! Default is 30466 = <code>E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR)</code> (see <a href="http://php.net/manual/en/errorfunc.constants.php" target="_blank">PHP documentation</a>).'
         exceptionalErrors:
             type: errors
             description: 'The E_* constant that will be converted into an exception by the default [SYS][errorHandler]. Default is 20480 = <code>E_ALL & ~(E_STRICT | E_NOTICE | E_COMPILE_WARNING | E_COMPILE_ERROR | E_CORE_WARNING | E_CORE_ERROR | E_PARSE | E_ERROR | E_DEPRECATED | E_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_WARNING)</code> (see <a href="http://php.net/manual/en/errorfunc.constants.php" target="_blank">PHP documentation</a>).'
-        syslogErrorReporting:
-            type: errors
-            description: 'Configures which PHP errors should be logged to the configured syslogs (see: [SYS][systemLog]). If set to "0" no PHP errors are logged to the syslog. Default is 30711 = <code>E_ALL & ~(E_STRICT | E_NOTICE)</code> (see <a href="http://php.net/manual/en/errorfunc.constants.php" target="_blank">PHP documentation</a>).'
         belogErrorReporting:
             type: errors
-            description: 'Configures which PHP errors should be logged to the "syslog" table (extension: belog). If set to "0" no PHP errors are logged to the sys_log table. Default is 30711 = <code>E_ALL & ~(E_STRICT | E_NOTICE)</code> (see <a href="http://php.net/manual/en/errorfunc.constants.php" target="_blank">PHP documentation</a>).'
+            description: 'Configures which PHP errors should be logged to the "syslog" database table (extension: belog). If set to "0" no PHP errors are logged to the sys_log table. Default is 30711 = <code>E_ALL & ~(E_STRICT | E_NOTICE)</code> (see <a href="http://php.net/manual/en/errorfunc.constants.php" target="_blank">PHP documentation</a>).'
         generateApacheHtaccess:
             type: bool
             description: 'TYPO3 can create <em>.htaccess</em> files which are used by Apache Webserver. They are useful for access protection or performance improvements. Currently <em>.htaccess</em> files in the following directories are created, if they do not exist: <ul><li>typo3temp/compressor/</li></ul>You want to disable this feature, if you are not running Apache or want to use own rulesets.'
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-82430-ReplacedGeneralUtilitysysLogWithLoggingAPI.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-82430-ReplacedGeneralUtilitysysLogWithLoggingAPI.rst
new file mode 100644 (file)
index 0000000..d427587
--- /dev/null
@@ -0,0 +1,46 @@
+.. include:: ../../Includes.txt
+
+===================================================================
+Breaking: #82430 - Replaced GeneralUtility::sysLog with Logging API
+===================================================================
+
+See :issue:`82430`
+
+Description
+===========
+
+The original sysLog() logging API has been superseded by the Logging API.
+
+Therefore, :php:`GeneralUtility::sysLog` and :php:`GeneralUtility::initSysLog` have been deprecated.
+
+The configuration :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']` has been changed to a boolean value.
+The option :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['syslogErrorReporting']` has been removed.
+
+Impact
+======
+
+The Logging API needs custom writer configuration to send the log entries of your choice to the
+PHP error log, the syslog facility or a file.
+
+
+Affected Installations
+======================
+
+Any instance having a configuration set for :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']`.
+
+
+Migration
+=========
+
+Add a custom log writer configuration to send log entries to the destination of your choice.
+
+The Logging API provides these writers as replacements for the original configuration options:
+
+- :php:`\TYPO3\CMS\Core\Log\Writer\SyslogWriter`
+- :php:`\TYPO3\CMS\Core\Log\Writer\PhpErrorLogWriter`
+- :php:`\TYPO3\CMS\Core\Log\Writer\FileWriter`
+
+More details on the configuration of log writers can be found in the Core API Reference
+at `<https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Logging/Writers/Index.html>`__.
+
+.. index:: LocalConfiguration, NotScanned
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82430-GeneralUtilitysysLog.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-82430-GeneralUtilitysysLog.rst
new file mode 100644 (file)
index 0000000..facb191
--- /dev/null
@@ -0,0 +1,34 @@
+.. include:: ../../Includes.txt
+
+============================================
+Deprecation: #82430 - GeneralUtility::sysLog
+============================================
+
+See :issue:`82430`
+
+Description
+===========
+
+The :php:`\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog` API is superseded by the Logging API.
+
+Therefore the methods :php:`GeneralUtility::sysLog` and :php:`GeneralUtility::initSysLog` have been marked as deprecated.
+
+
+Impact
+======
+
+Calling these methods triggers a deprecation log entry.
+
+
+Affected Installations
+======================
+
+Any TYPO3 installation having third party extensions using these methods.
+
+
+Migration
+=========
+
+Replace the :php:`GeneralUtility::sysLog` calls with direct calls to the Logging API.
+
+.. index:: PHP-API, NotScanned
\ No newline at end of file
index b5eb6ce..bb61408 100644 (file)
@@ -4251,29 +4251,8 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     }
 
     /////////////////////////////////////////////////////////////////////////////////////
-    // Tests concerning sysLog
+    // Tests concerning deprecation log
     /////////////////////////////////////////////////////////////////////////////////////
-    /**
-     * @test
-     */
-    public function syslogFixesPermissionsOnFileIfUsingFileLogging()
-    {
-        if (TYPO3_OS === 'WIN') {
-            $this->markTestSkipped(self::NO_FIX_PERMISSIONS_ON_WINDOWS);
-        }
-        // Fake all required settings
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = 0;
-        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = true;
-        unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']);
-        $testLogFilename = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('test_') . '.txt';
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = 'file,' . $testLogFilename . ',0';
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0777';
-        // Call method, get actual permissions and clean up
-        GeneralUtility::sysLog('testLog', 'test', GeneralUtility::SYSLOG_SEVERITY_NOTICE);
-        $this->testFilesToDelete[] = $testLogFilename;
-        clearstatcache();
-        $this->assertEquals('0777', substr(decoct(fileperms($testLogFilename)), 2));
-    }
 
     /**
      * @test
index aeb97a4..614dfdc 100644 (file)
@@ -14,10 +14,15 @@ namespace TYPO3\CMS\Extbase\Scheduler;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Mvc\Cli\CommandManager;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
+
 /**
  * Scheduler task to execute CommandController commands
  */
-class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
+class Task extends AbstractTask
 {
     /**
      * @var string
@@ -40,12 +45,12 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
     protected $objectManager;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
+     * @var CommandManager
      */
     protected $commandManager;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Scheduler\TaskExecutor
+     * @var TaskExecutor
      */
     protected $taskExecutor;
 
@@ -55,9 +60,9 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
     public function __construct()
     {
         parent::__construct();
-        $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-        $this->commandManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager::class);
-        $this->taskExecutor = $this->objectManager->get(\TYPO3\CMS\Extbase\Scheduler\TaskExecutor::class);
+        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+        $this->commandManager = $this->objectManager->get(CommandManager::class);
+        $this->taskExecutor = $this->objectManager->get(TaskExecutor::class);
     }
 
     /**
@@ -79,9 +84,9 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
      */
     public function __wakeup()
     {
-        $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-        $this->commandManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\CommandManager::class);
-        $this->taskExecutor = $this->objectManager->get(\TYPO3\CMS\Extbase\Scheduler\TaskExecutor::class);
+        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
+        $this->commandManager = $this->objectManager->get(CommandManager::class);
+        $this->taskExecutor = $this->objectManager->get(TaskExecutor::class);
     }
 
     /**
@@ -187,6 +192,6 @@ class Task extends \TYPO3\CMS\Scheduler\Task\AbstractTask
      */
     protected function logException(\Exception $e)
     {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($e->getMessage(), $this->commandIdentifier, \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
+        $this->logger->error('A Task (' . $this->commandIdentifier . ') Exception was captured: ' . $e->getMessage() . ' (' . $e->getCode() . ')', ['exception' => $e]);
     }
 }
index 6792f11..1b1ee91 100644 (file)
@@ -14,18 +14,23 @@ namespace TYPO3\CMS\Felogin\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Core\Crypto\Random;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
 
 /**
  * Plugin 'Website User Login' for the 'felogin' extension.
  */
-class FrontendLoginController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
+class FrontendLoginController extends AbstractPlugin implements LoggerAwareInterface
 {
+    use LoggerAwareTrait;
+
     /**
      * Same as class name
      *
@@ -1031,7 +1036,7 @@ class FrontendLoginController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
             return $url;
         }
         // URL is not allowed
-        GeneralUtility::sysLog(sprintf($this->pi_getLL('noValidRedirectUrl'), $url), 'felogin', GeneralUtility::SYSLOG_SEVERITY_WARNING);
+        $this->logger->warning('Url "' . $url . '" for redirect was not accepted!');
         return '';
     }
 
index 2e9250e..77f0ac2 100644 (file)
@@ -138,9 +138,6 @@ For security reasons, this link is only active until %s. If you do not visit the
                        <trans-unit id="ll_enter_your_data">
                                <source>Username or email address:</source>
                        </trans-unit>
-                       <trans-unit id="noValidRedirectUrl">
-                               <source>Url "%s" for redirect was not accepted!</source>
-                       </trans-unit>
                </body>
        </file>
 </xliff>
index 8dade80..56a98b1 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Felogin\Tests\Unit\Controller;
 
 use Prophecy\Argument;
 use Prophecy\Prophecy\ObjectProphecy;
+use Psr\Log\NullLogger;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
@@ -68,6 +69,7 @@ class FrontendLoginControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit
         $this->accessibleFixture = $this->getAccessibleMock(\TYPO3\CMS\Felogin\Controller\FrontendLoginController::class, ['dummy']);
         $this->accessibleFixture->cObj = $this->createMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
         $this->accessibleFixture->_set('frontendController', $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class));
+        $this->accessibleFixture->setLogger(new NullLogger());
         $this->setUpFakeSitePathAndHost();
     }
 
index 64ec04c..aec8c13 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Frontend\Controller;
  */
 
 use Doctrine\DBAL\Exception\ConnectionException;
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
@@ -66,8 +68,10 @@ use TYPO3\CMS\Frontend\View\AdminPanelView;
  * The use of this class should be inspired by the order of function calls as
  * found in \TYPO3\CMS\Frontend\Http\RequestHandler.
  */
-class TypoScriptFrontendController
+class TypoScriptFrontendController implements LoggerAwareInterface
 {
+    use LoggerAwareTrait;
+
     /**
      * The page id (int)
      * @var string
@@ -812,7 +816,7 @@ class TypoScriptFrontendController
                 $warning = '&no_cache=1 has been supplied, so caching is disabled! URL: "' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '"';
                 $this->disableCache();
             }
-            GeneralUtility::sysLog($warning, 'cms', GeneralUtility::SYSLOG_SEVERITY_WARNING);
+            $this->logger->warning($warning);
         }
         $this->cHash = $cHash;
         $this->MP = $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] ? (string)$MP : '';
@@ -869,7 +873,7 @@ class TypoScriptFrontendController
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit($message);
             } else {
-                GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                $this->logger->emergency($message, ['exception' => $exception]);
                 throw new ServiceUnavailableException($message, 1301648782);
             }
         }
@@ -1342,7 +1346,7 @@ class TypoScriptFrontendController
                     if ($this->checkPageUnavailableHandler()) {
                         $this->pageUnavailableAndExit($message);
                     } else {
-                        GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                        $this->logger->alert($message);
                         throw new ServiceUnavailableException($message, 1301648975);
                     }
                 }
@@ -1457,7 +1461,7 @@ class TypoScriptFrontendController
                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
                     $this->pageNotFoundAndExit($message);
                 } else {
-                    GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                    $this->logger->error($message);
                     throw new PageNotFoundException($message, 1301648780);
                 }
             }
@@ -1468,7 +1472,7 @@ class TypoScriptFrontendController
             if ($GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling']) {
                 $this->pageNotFoundAndExit($message);
             } else {
-                GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                $this->logger->error($message);
                 throw new PageNotFoundException($message, 1301648781);
             }
         }
@@ -1506,7 +1510,7 @@ class TypoScriptFrontendController
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit($message);
             } else {
-                GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                $this->logger->error($message);
                 throw new ServiceUnavailableException($message, 1301648167);
             }
         }
@@ -1517,7 +1521,7 @@ class TypoScriptFrontendController
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit($message);
                 } else {
-                    GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                    $this->logger->warning($message);
                     throw new ServiceUnavailableException($message, 1301648234);
                 }
             } else {
@@ -1595,7 +1599,7 @@ class TypoScriptFrontendController
             } else {
                 $pageLog[] = $page['uid'];
                 $message = 'Page shortcuts were looping in uids ' . implode(',', $pageLog) . '...!';
-                GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                $this->logger->error($message);
                 throw new \RuntimeException($message, 1294587212);
             }
         }
@@ -2441,7 +2445,7 @@ class TypoScriptFrontendController
                         $this->pageUnavailableAndExit($message);
                     } else {
                         $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
-                        GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                        $this->logger->alert($message);
                         throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
                     }
                 } else {
@@ -2487,7 +2491,7 @@ class TypoScriptFrontendController
                     $this->pageUnavailableAndExit('No TypoScript template found!');
                 } else {
                     $message = 'No TypoScript template found!';
-                    GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                    $this->logger->alert($message);
                     throw new ServiceUnavailableException($message, 1294587218);
                 }
             }
@@ -2589,7 +2593,7 @@ class TypoScriptFrontendController
         // If default translation is not available:
         if ((!$this->sys_language_uid || !$this->sys_language_content) && GeneralUtility::hideIfDefaultLanguage($this->page['l18n_cfg'])) {
             $message = 'Page is not available in default language.';
-            GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+            $this->logger->error($message);
             $this->pageNotFoundAndExit($message);
         }
         $this->updateRootLinesWithTranslations();
@@ -3941,17 +3945,11 @@ class TypoScriptFrontendController
     /**
      * Sets the cache-flag to 1. Could be called from user-included php-files in order to ensure that a page is not cached.
      *
-     * @param string $reason An optional reason to be written to the syslog.
+     * @param string $reason An optional reason to be written to the log.
      * @param bool $internal Whether the call is done from core itself (should only be used by core).
      */
     public function set_no_cache($reason = '', $internal = false)
     {
-        if ($internal && isset($GLOBALS['BE_USER'])) {
-            $severity = GeneralUtility::SYSLOG_SEVERITY_NOTICE;
-        } else {
-            $severity = GeneralUtility::SYSLOG_SEVERITY_WARNING;
-        }
-
         if ($reason !== '') {
             $warning = '$TSFE->set_no_cache() was triggered. Reason: ' . $reason . '.';
         } else {
@@ -3975,7 +3973,11 @@ class TypoScriptFrontendController
             $warning .= ' Caching is disabled!';
             $this->disableCache();
         }
-        GeneralUtility::sysLog($warning, 'cms', $severity);
+        if ($internal && isset($GLOBALS['BE_USER'])) {
+            $this->logger->notice($warning);
+        } else {
+            $this->logger->warning($warning);
+        }
     }
 
     /**
index 8717cd1..0ad4c75 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Frontend\Page;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
@@ -36,8 +38,10 @@ use TYPO3\CMS\Core\Versioning\VersionState;
  * functions operate properly
  * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::fetch_the_id()
  */
-class PageRepository
+class PageRepository implements LoggerAwareInterface
 {
+    use LoggerAwareTrait;
+
     /**
      * This is not the final clauses. There will normally be conditions for the
      * hidden, starttime and endtime fields as well. You MUST initialize the object
@@ -1816,7 +1820,7 @@ class PageRepository
              * Log the exception message for admins as they maybe can restore the storage
              */
             $logMessage = $e->getMessage() . ' (table: "' . $tableName . '", fieldName: "' . $fieldName . '", currentId: ' . $currentId . ')';
-            GeneralUtility::sysLog($logMessage, 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+            $this->logger->error($logMessage, ['exception' => $e]);
             return [];
         }
 
index d19d96a..6be88dd 100644 (file)
@@ -106,6 +106,8 @@ class SilentConfigurationUpgradeService
         'SYS/sqlDebug',
         'SYS/no_pconnect',
         'SYS/dbClientCompress',
+        // #82430
+        'SYS/syslogErrorReporting',
     ];
 
     public function __construct(ConfigurationManager $configurationManager = null)
index 672ff22..ca0c96b 100644 (file)
@@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -1257,7 +1258,9 @@ class AbstractDatabaseRecordList extends AbstractRecordList
                     }
                 }
             } else {
-                GeneralUtility::sysLog(sprintf('$TCA is broken for the table "%s": no required "columns" entry in $TCA.', $table), 'core', GeneralUtility::SYSLOG_SEVERITY_ERROR);
+                GeneralUtility::makeInstance(LogManager::class)
+                              ->getLogger(__CLASS__)
+                              ->error('TCA is broken for the table "' . $table . '": no required "columns" entry in TCA.');
             }
         }
         return $fieldListArr;
index bd6d78f..2ac113a 100644 (file)
@@ -33,6 +33,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
@@ -3656,11 +3657,9 @@ class DatabaseRecordList
                     }
                 }
             } else {
-                GeneralUtility::sysLog(
-                    sprintf('$TCA is broken for the table "%s": no required "columns" entry in $TCA.', $table),
-                    'core',
-                    GeneralUtility::SYSLOG_SEVERITY_ERROR
-                );
+                GeneralUtility::makeInstance(LogManager::class)
+                              ->getLogger(__CLASS__)
+                              ->error('TCA is broken for the table "' . $table . '": no required "columns" entry in TCA.');
             }
         }
         return $fieldListArr;
index ca31e93..dd24f88 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Saltedpasswords;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Authentication\AbstractAuthenticationService;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
@@ -79,9 +80,9 @@ class SaltedPasswordService extends AbstractAuthenticationService
         } elseif ($this->info['requestedServiceSubType'] === 'authUserFE') {
             $mode = 'FE';
         }
-        if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled($mode)) {
+        if (Utility\SaltedPasswordsUtility::isUsageEnabled($mode)) {
             $available = true;
-            $this->extConf = \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::returnExtConf();
+            $this->extConf = Utility\SaltedPasswordsUtility::returnExtConf();
         }
         return $available ? parent::init() : false;
     }
@@ -108,7 +109,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
             if (!$validPasswd) {
                 $this->authenticationFailed = true;
             }
-            $defaultHashingClassName = \TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::getDefaultSaltingHashingMethod();
+            $defaultHashingClassName = Utility\SaltedPasswordsUtility::getDefaultSaltingHashingMethod();
             $skip = false;
             // Test for wrong salted hashing method
             if ($validPasswd && !(get_class($this->objInstanceSaltedPW) == $defaultHashingClassName) || is_subclass_of($this->objInstanceSaltedPW, $defaultHashingClassName)) {
@@ -162,7 +163,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
      * - 100 - just go on. User is not authenticated but there is still no reason to stop
      * - 200 - the service was able to authenticate the user
      *
-     * @param array Array containing FE user data of the logged user.
+     * @param array $user Array containing FE user data of the logged user.
      * @return int Authentication statuscode, one of 0,100 and 200
      */
     public function authUser(array $user)
@@ -187,7 +188,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
                     $this->authInfo['REMOTE_HOST'],
                     $this->login['uname']
                 ]);
-                GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']), 'core', GeneralUtility::SYSLOG_SEVERITY_INFO);
+                $this->logger->info(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $this->login['uname']));
             } elseif ($validPasswd && $user['lockToDomain'] && strcasecmp($user['lockToDomain'], $this->authInfo['HTTP_HOST'])) {
                 // Lock domain didn't match, so error:
                 $errorMessage = 'Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!';
@@ -199,7 +200,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
                     $user['lockToDomain'],
                     $this->authInfo['HTTP_HOST']
                 ]);
-                GeneralUtility::sysLog(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']), 'core', GeneralUtility::SYSLOG_SEVERITY_INFO);
+                $this->logger->info(sprintf($errorMessage, $this->authInfo['REMOTE_ADDR'], $this->authInfo['REMOTE_HOST'], $user[$this->db_user['username_column']], $user['lockToDomain'], $this->authInfo['HTTP_HOST']));
                 $OK = 0;
             } elseif ($validPasswd) {
                 $this->writeLogMessage(TYPO3_MODE . ' Authentication successful for username \'%s\'', $this->login['uname']);
@@ -244,7 +245,6 @@ class SaltedPasswordService extends AbstractAuthenticationService
      *
      * @param string $message Message to output
      * @param array<int, mixed> $params
-     * @see \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog()
      */
     public function writeLogMessage($message, ...$params)
     {
@@ -252,7 +252,7 @@ class SaltedPasswordService extends AbstractAuthenticationService
             $message = vsprintf($message, $params);
         }
         if (TYPO3_MODE === 'BE') {
-            GeneralUtility::sysLog($message, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_NOTICE);
+            $this->logger->notice($message);
         } else {
             /** @var TimeTracker $timeTracker */
             $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
index 7a6fa94..9fc0ee3 100644 (file)
@@ -14,18 +14,22 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Log\LoggerAwareInterface;
+use Psr\Log\LoggerAwareTrait;
 use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
-use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Scheduler\Execution;
 
 /**
  * This is the base class for all Scheduler tasks
  * It's an abstract class, not designed to be instantiated directly
  * All Scheduler tasks should inherit from this class
  */
-abstract class AbstractTask
+abstract class AbstractTask implements LoggerAwareInterface
 {
+    use LoggerAwareTrait;
+
     const TYPE_SINGLE = 1;
     const TYPE_RECURRING = 2;
 
@@ -60,7 +64,7 @@ abstract class AbstractTask
     /**
      * The execution object related to the task
      *
-     * @var \TYPO3\CMS\Scheduler\Execution
+     * @var Execution
      */
     protected $execution;
 
@@ -91,7 +95,7 @@ abstract class AbstractTask
     public function __construct()
     {
         $this->setScheduler();
-        $this->execution = GeneralUtility::makeInstance(\TYPO3\CMS\Scheduler\Execution::class);
+        $this->execution = GeneralUtility::makeInstance(Execution::class);
     }
 
     /**
@@ -297,8 +301,8 @@ abstract class AbstractTask
      */
     public function registerSingleExecution($timestamp)
     {
-        /** @var $execution \TYPO3\CMS\Scheduler\Execution */
-        $execution = GeneralUtility::makeInstance(\TYPO3\CMS\Scheduler\Execution::class);
+        /** @var $execution Execution */
+        $execution = GeneralUtility::makeInstance(Execution::class);
         $execution->setStart($timestamp);
         $execution->setInterval(0);
         $execution->setEnd($timestamp);
@@ -320,8 +324,8 @@ abstract class AbstractTask
      */
     public function registerRecurringExecution($start, $interval, $end = 0, $multiple = false, $cron_cmd = '')
     {
-        /** @var $execution \TYPO3\CMS\Scheduler\Execution */
-        $execution = GeneralUtility::makeInstance(\TYPO3\CMS\Scheduler\Execution::class);
+        /** @var $execution Execution */
+        $execution = GeneralUtility::makeInstance(Execution::class);
         // Set general values
         $execution->setStart($start);
         $execution->setEnd($end);
@@ -342,9 +346,9 @@ abstract class AbstractTask
     /**
      * Sets the internal execution object
      *
-     * @param \TYPO3\CMS\Scheduler\Execution $execution The execution to add
+     * @param Execution $execution The execution to add
      */
-    public function setExecution(\TYPO3\CMS\Scheduler\Execution $execution)
+    public function setExecution(Execution $execution)
     {
         $this->execution = $execution;
     }
@@ -352,7 +356,7 @@ abstract class AbstractTask
     /**
      * Returns the execution object
      *
-     * @return \TYPO3\CMS\Scheduler\Execution The internal execution object
+     * @return Execution The internal execution object
      */
     public function getExecution()
     {
@@ -564,7 +568,7 @@ abstract class AbstractTask
      */
     public function stop()
     {
-        $this->execution = GeneralUtility::makeInstance(\TYPO3\CMS\Scheduler\Execution::class);
+        $this->execution = GeneralUtility::makeInstance(Execution::class);
     }
 
     /**
@@ -590,24 +594,10 @@ abstract class AbstractTask
     }
 
     /**
-     * Log exception via GeneralUtility::sysLog
-     *
      * @param \Exception $e
      */
     protected function logException(\Exception $e)
     {
-        GeneralUtility::sysLog($e->getMessage(), 'scheduler', GeneralUtility::SYSLOG_SEVERITY_ERROR);
-        $this->getLogger()->error('A Task Exception was captured: ' . $e->getMessage() . ' (' . $e->getCode() . ')', ['exception' => $e]);
-    }
-
-    /**
-     * Instantiates a logger
-     *
-     * @return \TYPO3\CMS\Core\Log\Logger
-     */
-    protected function getLogger()
-    {
-        $logManager = GeneralUtility::makeInstance(LogManager::class);
-        return $logManager->getLogger(static::class);
+        $this->logger->error('A Task Exception was captured: ' . $e->getMessage() . ' (' . $e->getCode() . ')', ['exception' => $e]);
     }
 }
index 09068a0..7f3e3bf 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Workspaces\Service;
  * 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\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -22,8 +24,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 /**
  * Grid data service
  */
-class GridDataService
+class GridDataService implements LoggerAwareInterface
 {
+    use LoggerAwareTrait;
+
     const SIGNAL_GenerateDataArray_BeforeCaching = 'generateDataArray.beforeCaching';
     const SIGNAL_GenerateDataArray_PostProcesss = 'generateDataArray.postProcess';
     const SIGNAL_GetDataArray_PostProcesss = 'getDataArray.postProcess';
@@ -368,11 +372,7 @@ class GridDataService
                     // Do nothing
             }
         } else {
-            GeneralUtility::sysLog(
-                'Try to sort "' . $this->sort . '" in "TYPO3\\CMS\\Workspaces\\Service\\GridDataService::sortDataArray" but $this->dataArray is empty! This might be the Bug #26422 which could not reproduced yet.',
-                'workspaces',
-                GeneralUtility::SYSLOG_SEVERITY_ERROR
-            );
+            $this->logger->critical('Try to sort "' . $this->sort . '" in "\\TYPO3\\CMS\\Workspaces\\Service\\GridDataService::sortDataArray" but $this->dataArray is empty! This might be the bug #26422 which could not be reproduced yet.');
         }
         // Suggested slot method:
         // methodName(\TYPO3\CMS\Workspaces\Service\GridDataService $gridData, array $dataArray, $sortColumn, $sortDirection)