mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-09 09:16:42 +00:00
working sentry-native
This commit is contained in:
16
src/Sentry.cpp
Normal file
16
src/Sentry.cpp
Normal 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();
|
||||
}
|
||||
18
src/main.cpp
18
src/main.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user