diff --git a/include/Compat.h b/include/Compat.h index 18d2b90..c68ebfe 100644 --- a/include/Compat.h +++ b/include/Compat.h @@ -12,9 +12,9 @@ using DWORD = unsigned long; using PDWORD = unsigned long*; using LPDWORD = unsigned long*; char _getch(); -inline void CloseSocketProper(int socket) { - shutdown(socket, SHUT_RDWR); - close(socket); +inline void CloseSocketProper(int TheSocket) { + shutdown(TheSocket, SHUT_RDWR); + close(TheSocket); } #endif // unix @@ -23,9 +23,9 @@ inline void CloseSocketProper(int socket) { #ifdef WIN32 #include #include -inline void CloseSocketProper(SOCKET socket) { - shutdown(socket, SD_BOTH); - closesocket(socket); +inline void CloseSocketProper(SOCKET TheSocket) { + shutdown(TheSocket, SD_BOTH); + closesocket(TheSocket); } #endif // WIN32 diff --git a/include/TSentry.h b/include/TSentry.h index ee76247..125aa75 100644 --- a/include/TSentry.h +++ b/include/TSentry.h @@ -4,6 +4,7 @@ #include #include +#include // TODO possibly use attach_stacktrace @@ -16,6 +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 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); @@ -25,6 +27,7 @@ public: private: bool mValid { true }; + std::mutex mMutex; }; #endif // SENTRY_H diff --git a/src/TSentry.cpp b/src/TSentry.cpp index b029333..75b3bd3 100644 --- a/src/TSentry.cpp +++ b/src/TSentry.cpp @@ -45,6 +45,11 @@ 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) { + SetTransaction(file + ":" + line); + Log(SENTRY_LEVEL_DEBUG, "default", file + ": " + text); +} + void TSentry::AddExtra(const std::string& key, const sentry_value_t& value) { if (!mValid) { return; diff --git a/src/TServer.cpp b/src/TServer.cpp index 7be220e..d2106f6 100644 --- a/src/TServer.cpp +++ b/src/TServer.cpp @@ -323,6 +323,10 @@ void TServer::Apply(TClient& c, int VID, const std::string& pckt) { std::string VD = c.GetCarData(VID); if (VD.empty()) { error("Tried to apply change to vehicle that does not exist"); + 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); return; } std::string Header = VD.substr(0, VD.find('{'));