Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Give the sentry client access to the TYPO3 logger #15

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Classes/Service/SentryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Sentry\ClientBuilder;
use Sentry\SentrySdk;
use Sentry\Tracing\TransactionContext;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class SentryService
{
Expand All @@ -21,6 +23,13 @@ public static function initialize(): void
"traces_sample_rate" => ConfigurationService::getTracesSampleRate()
]);

// 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());
}

Expand Down