CMakeLists: improve documentation, emit warning if no Sentry URL is

supplied
This commit is contained in:
Lion Kortlepel
2021-08-08 20:29:54 +02:00
committed by Lion
parent f550d0bba9
commit e6c97de3c4
2 changed files with 26 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ TSentry::TSentry(const std::string& SentryUrl) {
sentry_options_set_dsn(options, SentryUrl.c_str());
auto ReleaseString = "BeamMP-Server@" + Application::ServerVersion();
sentry_options_set_release(options, ReleaseString.c_str());
sentry_options_set_max_breadcrumbs(options, 10);
sentry_init(options);
}
}
@@ -21,14 +22,23 @@ TSentry::~TSentry() {
}
void TSentry::Log(sentry_level_t level, const std::string& logger, const std::string& text) {
if (!mValid) {
return;
}
sentry_capture_event(sentry_value_new_message_event(level, logger.c_str(), text.c_str()));
}
void TSentry::LogException(const std::exception& e, const std::string& file, const std::string& line) {
if (!mValid) {
return;
}
Log(SENTRY_LEVEL_ERROR, "exceptions", std::string(e.what()) + " @ " + file + ":" + line);
}
void TSentry::AddErrorBreadcrumb(const std::string& msg, const std::string& file, const std::string& line) {
if (!mValid) {
return;
}
auto crumb = sentry_value_new_breadcrumb("default", (msg + " @ " + file + ":" + line).c_str());
sentry_value_set_by_key(crumb, "level", sentry_value_new_string("error"));
sentry_add_breadcrumb(crumb);