From f4ffa2cddadb85b9a9660cb8bce106b4ef79b467 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Tue, 10 Aug 2021 12:35:33 +0200 Subject: [PATCH] Sentry: remove authkey, use id instead --- include/TSentry.h | 2 +- src/TSentry.cpp | 6 +++--- src/TServer.cpp | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/TSentry.h b/include/TSentry.h index e6e2537..25c706a 100644 --- a/include/TSentry.h +++ b/include/TSentry.h @@ -17,7 +17,7 @@ public: void PrintWelcome(); void SetupUser(); void Log(sentry_level_t level, const std::string& logger, const std::string& text); - void LogDebug(const std::string& text, const std::string& file, const std::string& line); + void LogError(const std::string& text, const std::string& file, const std::string& line); void AddExtra(const std::string& key, const sentry_value_t& value); void AddExtra(const std::string& key, const std::string& value); void LogException(const std::exception& e, const std::string& file, const std::string& line); diff --git a/src/TSentry.cpp b/src/TSentry.cpp index 984df10..35f7486 100644 --- a/src/TSentry.cpp +++ b/src/TSentry.cpp @@ -32,7 +32,6 @@ void TSentry::PrintWelcome() { void TSentry::SetupUser() { sentry_value_t user = sentry_value_new_object(); sentry_value_set_by_key(user, "id", sentry_value_new_string(Application::Settings.Key.c_str())); - sentry_value_set_by_key(user, "authkey", sentry_value_new_string(Application::Settings.Key.c_str())); sentry_set_user(user); } @@ -45,9 +44,9 @@ void TSentry::Log(sentry_level_t level, const std::string& logger, const std::st sentry_remove_transaction(); } -void TSentry::LogDebug(const std::string& text, const std::string& file, const std::string& line) { +void TSentry::LogError(const std::string& text, const std::string& file, const std::string& line) { SetTransaction(file + ":" + line); - Log(SENTRY_LEVEL_DEBUG, "default", file + ": " + text); + Log(SENTRY_LEVEL_ERROR, "default", file + ": " + text); } void TSentry::AddExtra(const std::string& key, const sentry_value_t& value) { @@ -68,6 +67,7 @@ void TSentry::LogException(const std::exception& e, const std::string& file, con if (!mValid) { return; } + SetTransaction(file + ":" + line); Log(SENTRY_LEVEL_ERROR, "exceptions", std::string(e.what()) + " @ " + file + ":" + line); } diff --git a/src/TServer.cpp b/src/TServer.cpp index 259edff..c43857d 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -327,13 +327,16 @@ void TServer::Apply(TClient& c, int VID, const std::string& pckt) { Sentry.AddExtra("packet", Packet); Sentry.AddExtra("vehicle-id", std::to_string(VID)); Sentry.AddExtra("client-car-count", std::to_string(c.GetCarCount())); - Sentry.LogDebug("attempt to apply change to nonexistent vehicle", _file_basename, _line); + Sentry.LogError("attempt to apply change to nonexistent vehicle", _file_basename, _line); return; } std::string Header = VD.substr(0, VD.find('{')); FoundPos = VD.find('{'); if (FoundPos == std::string::npos) { + auto Lock = Sentry.CreateExclusiveContext(); + Sentry.AddExtra("packet", VD); + Sentry.LogError("malformed packet", _file_basename, _line); error("Malformed packet received, no '{' found"); return; }