Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions loader/resources/mod.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@
"name": "Expand Installed Mods List",
"description": "Make the installed mods list a single infinite scrollable list instead of having pages"
},
"hide-user-in-crashlogs": {
"type": "bool",
"default": true,
"name": "Hide Name in Crashlogs",
"description": "Replaces your username with \"<user>\" in crashlogs so you can share crashlogs without leaking your name.",
"platforms": [
"win",
"mac"
]
},
"developer-title": {
"type": "title",
"name": "Developer Settings"
Expand Down
21 changes: 19 additions & 2 deletions loader/src/internal/crashlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,23 @@ std::string crashlog::writeCrashlog(
// this could also be done by saving a loader setting or smth but eh.
(void)utils::file::writeBinary(crashlog::getCrashLogDirectory() / "last-crashed", {});

auto newInfo = std::string(info);
auto newStack = std::string(stacktrace);

#if defined(GEODE_IS_WINDOWS) || defined(GEODE_IS_MACOS)
if (Mod::get()->getSettingValue<bool>("hide-user-in-crashlogs")) {
const char* user = std::getenv("USER");
std::string newUser = "<user>";

// so we only replace file paths
newInfo = utils::string::replace(newInfo, fmt::format("\\{}\\", user), fmt::format("\\{}\\", newUser));
newInfo = utils::string::replace(newInfo, fmt::format("/{}/", user), fmt::format("/{}/", newUser));

newStack = utils::string::replace(newStack, fmt::format("\\{}\\", user), fmt::format("\\{}\\", newUser));
newStack = utils::string::replace(newStack, fmt::format("/{}/", user), fmt::format("/{}/", newUser));
}
#endif

Buffer file;

file.append(getDateString(false));
Expand All @@ -290,11 +307,11 @@ std::string crashlog::writeCrashlog(

// exception info
file.append("\n== Exception Information ==\n");
file.append(info);
file.append(newInfo);

// stack trace
file.append("\n== Stack Trace (the most important part) ==\n");
file.append(stacktrace);
file.append(newStack);

// registers
file.append("\n== Register States ==\n");
Expand Down
Loading