working sentry-native

This commit is contained in:
Lion Kortlepel
2021-08-08 00:28:30 +02:00
committed by Lion
parent d5769ce9be
commit da41862f49
4 changed files with 51 additions and 3 deletions

16
src/Sentry.cpp Normal file
View File

@@ -0,0 +1,16 @@
#include "Sentry.h"
#include "Common.h"
#include "sentry.h"
Sentry::Sentry(const std::string& SentryUrl) {
sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, SentryUrl.c_str());
auto ReleaseString = "BeamMP-Server@" + Application::ServerVersion();
sentry_options_set_release(options, ReleaseString.c_str());
sentry_init(options);
}
Sentry::~Sentry() {
sentry_close();
}

View File

@@ -1,5 +1,6 @@
#include "Common.h"
#include "Http.h"
#include "Sentry.h"
#include "TConfig.h"
#include "THeartbeatThread.h"
#include "TLuaEngine.h"
@@ -7,6 +8,8 @@
#include "TPPSMonitor.h"
#include "TResourceManager.h"
#include "TServer.h"
#include <sentry.h>
#include <thread>
#ifdef __unix
@@ -44,6 +47,21 @@ int main(int argc, char** argv) {
#endif // DEBUG
#endif // __unix
// FIXME: this is not prod ready, needs to be compile-time value
char* sentry_url = getenv("SENTRY_URL");
if (!sentry_url) {
error("no sentry url supplied in environment, this is not a fatal error");
} else {
info("sentry url has length " + std::to_string(std::string(sentry_url).size()));
}
Sentry sentry(sentry_url);
sentry_capture_event(sentry_value_new_message_event(
/* level */ SENTRY_LEVEL_INFO,
/* logger */ "custom",
/* message */ "It works!"));
setlocale(LC_ALL, "C");
bool Shutdown = false;