From fa40a6d1b898568d99230396737af28316ec34a2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 23 Apr 2021 12:46:48 +0100 Subject: [PATCH] Error reports: default to SG_LOG(SG_ALERT When no callback is registered, just fall back to a plain SG_ALERT --- simgear/debug/ErrorReportingCallback.cxx | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/simgear/debug/ErrorReportingCallback.cxx b/simgear/debug/ErrorReportingCallback.cxx index 361f6c0a..5e0c483d 100644 --- a/simgear/debug/ErrorReportingCallback.cxx +++ b/simgear/debug/ErrorReportingCallback.cxx @@ -16,6 +16,7 @@ #include #include "ErrorReportingCallback.hxx" +#include "logstream.hxx" #include @@ -27,6 +28,31 @@ static ErrorReportCallback static_callback; static ContextCallback static_contextCallback; +string_list static_errorNames = { + "shader/effect", + "loading texture", + "XML/animation load", + "3D model load", + "loading BTG", + "sceanrio load", + "UI dialog load", + "loading Audio/FX", + "Nasal/commnad load of XML", + "aircraft-systems", + "loading input/joystick config", + "load AI/traffic", + "from TerraSync"}; + +string_list static_errorTypeNames = { + "unknown", + "not found", + "out of memory", + "bad header", + "bad data", + "misconfigured", + "disk IO/permissions", + "network IO"}; + void setErrorReportCallback(ErrorReportCallback cb) { static_callback = cb; @@ -53,6 +79,7 @@ static FailureCallback static_failureCallback; void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, sg_location loc) { if (!static_failureCallback) { + SG_LOG(SG_GENERAL, SG_WARN, "Error:" << static_errorTypeNames.at(static_cast(type)) << " from " << static_errorNames.at(static_cast(code)) << "::" << details << "\n\t" << loc.asString()); return; } @@ -62,6 +89,9 @@ void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, void reportFailure(LoadFailure type, ErrorCode code, const std::string& details, const SGPath& path) { if (!static_failureCallback) { + // if no callback is registered, log here instead + SG_LOG(SG_GENERAL, SG_WARN, "Error:" << static_errorTypeNames.at(static_cast(type)) << " from " << static_errorNames.at(static_cast(code)) << "::" << details << "\n\t" << path); + return; }