mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-03 14:26:09 +00:00
Sentry: implement basic exception reporting, error breadcrumbs
This commit is contained in:
26
src/main.cpp
26
src/main.cpp
@@ -35,7 +35,11 @@ void UnixSignalHandler(int sig) {
|
||||
}
|
||||
#endif // __unix
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// this is provided by the build system, leave empty for source builds
|
||||
// global, yes, this is ugly, no, it cant be done another way
|
||||
TSentry Sentry { SECRET_SENTRY_URL };
|
||||
|
||||
int main(int argc, char** argv) try {
|
||||
#ifdef __unix
|
||||
#if DEBUG
|
||||
info("registering handlers for SIGINT, SIGTERM, SIGPIPE");
|
||||
@@ -46,27 +50,12 @@ int main(int argc, char** argv) {
|
||||
signal(SIGINT, UnixSignalHandler);
|
||||
#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;
|
||||
Application::RegisterShutdownHandler([&Shutdown] { Shutdown = true; });
|
||||
|
||||
|
||||
TServer Server(argc, argv);
|
||||
TConfig Config;
|
||||
|
||||
@@ -89,4 +78,7 @@ int main(int argc, char** argv) {
|
||||
while (!Shutdown) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
error(e.what());
|
||||
Sentry.LogException(e, _file_basename, _line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user