1
0
Fork 0

Disable Sentry if init fails

This will fix other uses of the APi blocking because the backend
failed to start. Enable debug logging in non-release builds so
it's obvious when the deploymenty is not configured right.
This commit is contained in:
James Turner 2021-12-19 12:38:52 +00:00
parent 271073d869
commit 5f66ffc96b

View file

@ -278,7 +278,12 @@ void initSentry()
const auto buildString = std::to_string(JENKINS_BUILD_NUMBER); const auto buildString = std::to_string(JENKINS_BUILD_NUMBER);
sentry_options_set_dist(options, buildString.c_str()); sentry_options_set_dist(options, buildString.c_str());
// for dev / nightly builds, put Sentry in debug mode
if (strcmp(FG_BUILD_TYPE, "Release")) {
sentry_options_set_debug(options, 1);
}
SGPath dataPath = fgHomePath() / "sentry_db"; SGPath dataPath = fgHomePath() / "sentry_db";
#if defined(SG_WINDOWS) #if defined(SG_WINDOWS)
const auto homePathString = dataPath.wstr(); const auto homePathString = dataPath.wstr();
@ -320,19 +325,22 @@ void initSentry()
f << uuid << endl; f << uuid << endl;
} }
sentry_init(options); if (sentry_init(options) == 0) {
static_sentryEnabled = true; static_sentryEnabled = true;
sentry_value_t user = sentry_value_new_object();
sentry_value_t userUuidV = sentry_value_new_string(uuid.c_str());
sentry_value_set_by_key(user, "id", userUuidV);
sentry_set_user(user);
sentry_value_t user = sentry_value_new_object(); sglog().addCallback(new SentryLogCallback);
sentry_value_t userUuidV = sentry_value_new_string(uuid.c_str()); setThrowCallback(sentryTraceSimgearThrow);
sentry_value_set_by_key(user, "id", userUuidV); simgear::setErrorReportCallback(sentrySimgearReportCallback);
sentry_set_user(user);
sglog().addCallback(new SentryLogCallback); std::set_new_handler(sentryReportBadAlloc);
setThrowCallback(sentryTraceSimgearThrow); } else {
simgear::setErrorReportCallback(sentrySimgearReportCallback); SG_LOG(SG_GENERAL, SG_WARN, "Failed to init Sentry reporting");
static_sentryEnabled = false;
std::set_new_handler(sentryReportBadAlloc); }
} }
void delayedSentryInit() void delayedSentryInit()