Logging for Nasal errors, disabled for now.
Code to log Nasal, as well as C++, errors. But need a way to reduce the false-positive rate, so disabled for now.
This commit is contained in:
parent
b016c4b489
commit
fdd509a080
4 changed files with 54 additions and 5 deletions
|
@ -101,6 +101,35 @@ void addSentryTag(const char* tag, const char* value)
|
||||||
sentry_set_tag(tag, value);
|
sentry_set_tag(tag, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sentryReportNasalError(const std::string& msg, const string_list& stack)
|
||||||
|
{
|
||||||
|
if (!static_sentryEnabled)
|
||||||
|
return;
|
||||||
|
#if 0
|
||||||
|
sentry_value_t exc = sentry_value_new_object();
|
||||||
|
sentry_value_set_by_key(exc, "type", sentry_value_new_string("Exception"));
|
||||||
|
sentry_value_set_by_key(exc, "value", sentry_value_new_string(msg.c_str()));
|
||||||
|
|
||||||
|
sentry_value_t stackData = sentry_value_new_list();
|
||||||
|
for (const auto& nasalFrame : stack) {
|
||||||
|
sentry_value_append(stackData, sentry_value_new_string(nasalFrame.c_str()));
|
||||||
|
}
|
||||||
|
sentry_value_set_by_key(exc, "stack", stackData);
|
||||||
|
|
||||||
|
|
||||||
|
sentry_value_t event = sentry_value_new_event();
|
||||||
|
sentry_value_set_by_key(event, "exception", exc);
|
||||||
|
|
||||||
|
// add the Nasal stack trace data
|
||||||
|
|
||||||
|
// capture the C++ stack-trace. Probably not that useful but can't hurt
|
||||||
|
sentry_event_value_add_stacktrace(event, nullptr, 0);
|
||||||
|
|
||||||
|
sentry_capture_event(event);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // of namespace
|
} // of namespace
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -131,6 +160,10 @@ void addSentryTag(const char*, const char*)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sentryReportNasalError(const std::string&, const string_list&)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} // of namespace
|
} // of namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <simgear/misc/strutils.hxx>
|
||||||
|
|
||||||
namespace flightgear
|
namespace flightgear
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,7 @@ void addSentryTag(const char* tag, const char* value);
|
||||||
|
|
||||||
void addSentryTag(const std::string& tag, const std::string& value);
|
void addSentryTag(const std::string& tag, const std::string& value);
|
||||||
|
|
||||||
|
void sentryReportNasalError(const std::string& msg, const string_list& stack);
|
||||||
|
|
||||||
} // of namespace flightgear
|
} // of namespace flightgear
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Main/util.hxx>
|
#include <Main/util.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
#include <Main/sentryIntegration.hxx>
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -310,7 +311,9 @@ naRef FGNasalSys::callMethodWithContext(naContext ctx, naRef code, naRef self, i
|
||||||
return naCallMethodCtx(ctx, code, self, argc, args, locals);
|
return naCallMethodCtx(ctx, code, self, argc, args, locals);
|
||||||
} catch (sg_exception& e) {
|
} catch (sg_exception& e) {
|
||||||
SG_LOG(SG_NASAL, SG_DEV_ALERT, "caught exception invoking nasal method:" << e.what());
|
SG_LOG(SG_NASAL, SG_DEV_ALERT, "caught exception invoking nasal method:" << e.what());
|
||||||
logNasalStack(ctx);
|
string_list nasalStack;
|
||||||
|
logNasalStack(ctx, nasalStack);
|
||||||
|
flightgear::sentryReportNasalError(string{"Exception invoking nasal method:"} + e.what(), nasalStack);
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1305,23 +1308,34 @@ void FGNasalSys::loadPropertyScripts(SGPropertyNode* n)
|
||||||
// Logs a runtime error, with stack trace, to the FlightGear log stream
|
// Logs a runtime error, with stack trace, to the FlightGear log stream
|
||||||
void FGNasalSys::logError(naContext context)
|
void FGNasalSys::logError(naContext context)
|
||||||
{
|
{
|
||||||
SG_LOG(SG_NASAL, SG_ALERT, "Nasal runtime error: " << naGetError(context));
|
string errorMessage = naGetError(context);
|
||||||
logNasalStack(context);
|
SG_LOG(SG_NASAL, SG_ALERT, "Nasal runtime error: " << errorMessage);
|
||||||
|
|
||||||
|
string_list nasalStack;
|
||||||
|
logNasalStack(context, nasalStack);
|
||||||
|
flightgear::sentryReportNasalError(errorMessage, nasalStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGNasalSys::logNasalStack(naContext context)
|
void FGNasalSys::logNasalStack(naContext context, string_list& stack)
|
||||||
{
|
{
|
||||||
const int stack_depth = naStackDepth(context);
|
const int stack_depth = naStackDepth(context);
|
||||||
if (stack_depth < 1)
|
if (stack_depth < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
stack.push_back(string{naStr_data(naGetSourceFile(context, 0))} +
|
||||||
|
", line " + std::to_string(naGetLine(context, 0)));
|
||||||
|
|
||||||
SG_LOG(SG_NASAL, SG_ALERT,
|
SG_LOG(SG_NASAL, SG_ALERT,
|
||||||
" at " << naStr_data(naGetSourceFile(context, 0)) <<
|
" at " << naStr_data(naGetSourceFile(context, 0)) <<
|
||||||
", line " << naGetLine(context, 0));
|
", line " << naGetLine(context, 0));
|
||||||
|
|
||||||
for(int i=1; i<stack_depth; i++) {
|
for(int i=1; i<stack_depth; i++) {
|
||||||
SG_LOG(SG_NASAL, SG_ALERT,
|
SG_LOG(SG_NASAL, SG_ALERT,
|
||||||
" called from: " << naStr_data(naGetSourceFile(context, i)) <<
|
" called from: " << naStr_data(naGetSourceFile(context, i)) <<
|
||||||
", line " << naGetLine(context, i));
|
", line " << naGetLine(context, i));
|
||||||
|
|
||||||
|
stack.push_back(string{naStr_data(naGetSourceFile(context, i))} +
|
||||||
|
", line " + std::to_string(naGetLine(context, i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ private:
|
||||||
void addPersistentTimer(TimerObj* pto);
|
void addPersistentTimer(TimerObj* pto);
|
||||||
void removePersistentTimer(TimerObj* obj);
|
void removePersistentTimer(TimerObj* obj);
|
||||||
|
|
||||||
static void logNasalStack(naContext context);
|
static void logNasalStack(naContext context, string_list& stack);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Loading…
Reference in a new issue