[TASK] Log signal dispatching to debug log 22/56822/2
authorSusanne Moog <susanne.moog@typo3.org>
Fri, 27 Apr 2018 09:37:34 +0000 (11:37 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 28 Apr 2018 04:18:44 +0000 (06:18 +0200)
To be able to find out which signals are triggered
during requests debug logging has been implemented
in the SignalSlotDispatcher.

Related: #84044
Resolves: #84888
Releases: master
Change-Id: I2c25c51644e8294848f8f053908984d85c5a1e83
Reviewed-on: https://review.typo3.org/56822
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/extbase/Classes/SignalSlot/Dispatcher.php

index 1cb17e7..afe043a 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Extbase\SignalSlot;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Log\LogManager;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * A dispatcher which dispatches signals by calling its registered slot methods
  * and passing them the method arguments which were originally passed to the
@@ -110,6 +113,16 @@ class Dispatcher implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function dispatch($signalClassName, $signalName, array $signalArguments = [])
     {
+        // We can't use LoggerAwaireTrait/Interface here as this class is singleton and instanciated
+        // too early (before loading of ext_localconf.php of extensions) so any logger configuration
+        // done in an extension won't be used if injecting the logger at creation time
+        $logManager = GeneralUtility::makeInstance(LogManager::class);
+        $logger = $logManager->getLogger(self::class);
+        $logger->log(LOG_DEBUG, 'Triggered signal ' . $signalClassName . ' ' . $signalName, [
+            'signalClassName' => $signalClassName,
+            'signalName' => $signalName,
+            'signalArguments' => $signalArguments
+        ]);
         $this->initializeObject();
         if (!isset($this->slots[$signalClassName][$signalName])) {
             return $signalArguments;