mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-02-16 10:41:01 +00:00
Sentry: implement basic exception reporting, error breadcrumbs
This commit is contained in:
@@ -79,6 +79,9 @@ void RegisterThread(const std::string str);
|
||||
#define _line std::to_string(__LINE__)
|
||||
#define _in_lambda (std::string(__func__) == "operator()")
|
||||
|
||||
#include "Sentry.h"
|
||||
extern TSentry Sentry;
|
||||
|
||||
// we would like the full function signature 'void a::foo() const'
|
||||
// on windows this is __FUNCSIG__, on GCC it's __PRETTY_FUNCTION__,
|
||||
// feel free to add more
|
||||
@@ -108,7 +111,7 @@ void RegisterThread(const std::string str);
|
||||
|
||||
#define warn(x) Application::Console().Write(_this_location + std::string("[WARN] ") + (x))
|
||||
#define info(x) Application::Console().Write(_this_location + std::string("[INFO] ") + (x))
|
||||
#define error(x) Application::Console().Write(_this_location + std::string("[ERROR] ") + (x))
|
||||
#define error(x) do { Application::Console().Write(_this_location + std::string("[ERROR] ") + (x)); Sentry.AddErrorBreadcrumb((x), _file_basename, _line); } while (false)
|
||||
#define luaprint(x) Application::Console().Write(_this_location + std::string("[LUA] ") + (x))
|
||||
#define debug(x) \
|
||||
do { \
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
#ifndef SENTRY_H
|
||||
#define SENTRY_H
|
||||
|
||||
#include <sentry.h>
|
||||
#include <string>
|
||||
|
||||
enum class Logger {
|
||||
|
||||
};
|
||||
|
||||
// singleton, dont make this twice
|
||||
class Sentry final {
|
||||
class TSentry final {
|
||||
public:
|
||||
Sentry(const std::string& SentryUrl);
|
||||
~Sentry();
|
||||
TSentry(const std::string& SentryUrl);
|
||||
~TSentry();
|
||||
|
||||
void Log(sentry_level_t level, const std::string& logger, const std::string& text);
|
||||
void LogException(const std::exception& e, const std::string& file, const std::string& line);
|
||||
void AddErrorBreadcrumb(const std::string& msg, const std::string& file, const std::string& line);
|
||||
|
||||
private:
|
||||
bool mValid { true };
|
||||
};
|
||||
|
||||
#endif // SENTRY_H
|
||||
|
||||
Reference in New Issue
Block a user