From 33aafbc7955524cc865ff41d72774b3fbbddd04f Mon Sep 17 00:00:00 2001 From: Johannes Przymusinski Date: Sat, 30 Oct 2021 14:08:49 +0200 Subject: [PATCH] [TASK] Attatch a logger to the SentryClient --- Classes/Service/SentryService.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Classes/Service/SentryService.php b/Classes/Service/SentryService.php index f597215..0cfe824 100644 --- a/Classes/Service/SentryService.php +++ b/Classes/Service/SentryService.php @@ -4,6 +4,8 @@ use Sentry\ClientBuilder; use Sentry\SentrySdk; +use TYPO3\CMS\Core\Log\LogManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; class SentryService { @@ -19,6 +21,13 @@ public static function initialize(): void "environment" => ConfigurationService::getEnvironment() ]); + // We need to use the GeneralUtility to instantiate a LogManager, because we can't use either + // DependencyInjection or the LoggerAwareTrait. + $clientBuilder->setLogger( + GeneralUtility::makeInstance(LogManager::class) + ->getLogger("Sentry-Client") // TODO: The name of the logger should be configurable + ); + SentrySdk::init()->bindClient($clientBuilder->getClient()); }