troubleshooter: add more detection (#397)

## Description of change
Detect and log troubleshooter messages for:

* (early) hook DLL load failure
* data_mods folder without ifs_hook.dll
* spice version (print out current version and add a link to github
download)

## Testing
This commit is contained in:
bicarus-dev
2025-10-06 08:03:06 -07:00
committed by GitHub
parent 8cc00c371a
commit 58ea6ce17e
3 changed files with 48 additions and 19 deletions
+22 -12
View File
@@ -1,6 +1,7 @@
#include <mutex>
#include <atomic>
#include "build/defs.h"
#include "deferlog.h"
#include "util/logging.h"
@@ -39,27 +40,36 @@ namespace deferredlogs {
errors = std::move(deferred_errors);
}
log_warning("troubleshooter", "/------------------------ spice2x auto-troubleshooter ------------------------\\");
log_warning("troubleshooter", "");
std::string msg;
msg += "\n\n";
msg += "/-------------------------- spice2x auto-troubleshooter -----------------------\\\n";
msg += "\n";
msg += " spice2x version: " + to_string(VERSION_STRING_CFG) + "\n";
msg += "\n";
if (is_crash) {
log_warning("troubleshooter", " the game has crashed");
log_warning("troubleshooter", " share this entire log file with someone for troubleshooting");
log_warning("troubleshooter", " spice will also attempt to create a minidump (minidump.dmp)");
log_warning("troubleshooter", "");
msg += " the game has crashed\n";
msg += " share this entire log file with someone for troubleshooting (log.txt)\n";
msg += " spice will also attempt to create a minidump (minidump.dmp)\n";
msg += "\n";
}
for (auto messages : errors) {
for (auto message : messages) {
log_warning("troubleshooter", " {}", message);
msg += " " + message + "\n";
}
log_warning("troubleshooter", "");
msg += "\n";
}
log_warning("troubleshooter", " unsure what to do next? check the FAQ:");
log_warning("troubleshooter", " https://github.com/spice2x/spice2x.github.io/wiki/Known-issues");
log_warning("troubleshooter", "");
log_warning("troubleshooter", "\\------------------------ spice2x auto-troubleshooter -----------------------/");
msg += " unsure what to do next?\n";
msg += " * update to the latest version:\n";
msg += " https://github.com/spice2x/spice2x.github.io/releases/latest\n";
msg += " * check the FAQ:\n";
msg += " https://github.com/spice2x/spice2x.github.io/wiki/Known-issues\n";
msg += "\n";
msg += "\\------------------------- spice2x auto-troubleshooter ------------------------/\n";
log_warning("troubleshooter", "{}", msg);
});
}
}
+8 -2
View File
@@ -283,7 +283,8 @@ static inline std::string get_last_error_string() {
LPSTR messageBuffer = nullptr;
size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK,
nullptr,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
@@ -292,7 +293,12 @@ static inline std::string get_last_error_string() {
nullptr);
// return as string
std::string message(messageBuffer, size);
std::string message;
if (size == 0) {
message = fmt::format("(Win32 error {})", error);
} else {
message = fmt::format("{}(Win32 error {})", messageBuffer, error);
}
LocalFree(messageBuffer);
return message;