Bladeren bron

replace old logger by new OtLogger service

Olivier Massot 2 jaren geleden
bovenliggende
commit
e59aeb776c
1 gewijzigde bestanden met toevoegingen van 3 en 29 verwijderingen
  1. 3 29
      ot_connect/Classes/Service/OtAuthenticationService.php

+ 3 - 29
ot_connect/Classes/Service/OtAuthenticationService.php

@@ -7,6 +7,7 @@ use GuzzleHttp\Cookie\SetCookie;
 use GuzzleHttp\Exception\GuzzleException;
 use GuzzleHttp\Exception\RequestException;
 use Opentalent\OtCore\Exception\ApiRequestException;
+use Opentalent\OtCore\Logging\OtLogger;
 use Opentalent\OtCore\Service\OpentalentApiService;
 use TYPO3\CMS\Core\Crypto\Random;
 use TYPO3\CMS\Core\Database\ConnectionPool;
@@ -342,7 +343,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
                 if ($groupUid) {
                     $groupsUid[] = $groupUid;
                 } else {
-                    $this->writeLogMessage("Warning: no fe_group found for organization " . $organizationId);
+                    OtLogger::warning("Warning: no fe_group found for organization " . $organizationId);
                 }
             }
         }
@@ -364,7 +365,7 @@ class OtAuthenticationService extends AbstractAuthenticationService
         } else {
             // User exists: update
             if (!$tx_opentalent_opentalentId > 0) {
-                $this->writeLogMessage('WARNING: FE user ' . $userApiData['username'] . ' has been replaced by an auto-generated version.');
+                OtLogger::warning('WARNING: FE user ' . $userApiData['username'] . ' has been replaced by an auto-generated version.');
             }
             $connection->update('fe_users', $fe_row, ['uid' => $uid]);
         }
@@ -464,31 +465,4 @@ class OtAuthenticationService extends AbstractAuthenticationService
         setcookie($name, '', 1, '/', $_SERVER['HTTP_HOST']); // for custom domains (not in .opentalent.fr)
         setcookie($name, '', 1, '/', self::COOKIE_DOMAIN);   // for opentalent.fr subdomains
     }
-
-    /**
-     * Writes log message. Destination log depends on the current system mode.
-     * For FE the function writes to the admin panel log. For BE messages are
-     * sent to the system log. If developer log is enabled, messages are also
-     * sent there.
-     *
-     * This function accepts variable number of arguments and can format
-     * parameters. The syntax is the same as for sprintf()
-     *
-     * @param string $message Message to output
-     * @param array<int, mixed> $params
-     * @see \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog()
-     */
-    public function writeLogMessage($message, ...$params)
-    {
-        if (!empty($params)) {
-            $message = vsprintf($message, $params);
-        }
-        if (TYPO3_MODE === 'BE') {
-            GeneralUtility::sysLog($message, 'ot_connect');
-        } else {
-            /** @var TimeTracker $timeTracker */
-            $timeTracker = GeneralUtility::makeInstance(TimeTracker::class);
-            $timeTracker->setTSlogMessage($message);
-        }
-    }
 }