Sentry: remove authkey, use id instead

This commit is contained in:
Lion Kortlepel
2021-08-10 12:35:33 +02:00
committed by Lion
parent 1409d4ef80
commit f4ffa2cdda
3 changed files with 8 additions and 5 deletions

View File

@@ -17,7 +17,7 @@ public:
void PrintWelcome(); void PrintWelcome();
void SetupUser(); void SetupUser();
void Log(sentry_level_t level, const std::string& logger, const std::string& text); 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 sentry_value_t& value);
void AddExtra(const std::string& key, const std::string& 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); void LogException(const std::exception& e, const std::string& file, const std::string& line);

View File

@@ -32,7 +32,6 @@ void TSentry::PrintWelcome() {
void TSentry::SetupUser() { void TSentry::SetupUser() {
sentry_value_t user = sentry_value_new_object(); 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, "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); 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(); 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); 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) { 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) { if (!mValid) {
return; return;
} }
SetTransaction(file + ":" + line);
Log(SENTRY_LEVEL_ERROR, "exceptions", std::string(e.what()) + " @ " + file + ":" + line); Log(SENTRY_LEVEL_ERROR, "exceptions", std::string(e.what()) + " @ " + file + ":" + line);
} }

View File

@@ -327,13 +327,16 @@ void TServer::Apply(TClient& c, int VID, const std::string& pckt) {
Sentry.AddExtra("packet", Packet); Sentry.AddExtra("packet", Packet);
Sentry.AddExtra("vehicle-id", std::to_string(VID)); Sentry.AddExtra("vehicle-id", std::to_string(VID));
Sentry.AddExtra("client-car-count", std::to_string(c.GetCarCount())); 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; return;
} }
std::string Header = VD.substr(0, VD.find('{')); std::string Header = VD.substr(0, VD.find('{'));
FoundPos = VD.find('{'); FoundPos = VD.find('{');
if (FoundPos == std::string::npos) { 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"); error("Malformed packet received, no '{' found");
return; return;
} }