crashReporter: log on crash

This commit is contained in:
vaxerski 2023-04-21 16:48:30 +01:00
parent 458ea56b86
commit 7b5b4a1049

View file

@ -135,13 +135,15 @@ void CrashReporter::createAndSaveCrash(int sig) {
return; return;
std::ofstream ofs; std::ofstream ofs;
std::string path;
if (!CACHE_HOME) { if (!CACHE_HOME) {
if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) { if (!std::filesystem::exists(std::string(HOME) + "/.hyprland")) {
std::filesystem::create_directory(std::string(HOME) + "/.hyprland"); std::filesystem::create_directory(std::string(HOME) + "/.hyprland");
std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace); std::filesystem::permissions(std::string(HOME) + "/.hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace);
} }
ofs.open(std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc); path = std::string(HOME) + "/.hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt";
ofs.open(path, std::ios::trunc);
} else if (CACHE_HOME) { } else if (CACHE_HOME) {
if (!std::filesystem::exists(std::string(CACHE_HOME) + "/hyprland")) { if (!std::filesystem::exists(std::string(CACHE_HOME) + "/hyprland")) {
@ -149,7 +151,8 @@ void CrashReporter::createAndSaveCrash(int sig) {
std::filesystem::permissions(std::string(CACHE_HOME) + "/hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace); std::filesystem::permissions(std::string(CACHE_HOME) + "/hyprland", std::filesystem::perms::all, std::filesystem::perm_options::replace);
} }
ofs.open(std::string(CACHE_HOME) + "/hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt", std::ios::trunc); path = std::string(CACHE_HOME) + "/hyprland/hyprlandCrashReport" + std::to_string(PID) + ".txt";
ofs.open(path, std::ios::trunc);
} else { } else {
return; return;
} }
@ -157,4 +160,7 @@ void CrashReporter::createAndSaveCrash(int sig) {
ofs << finalCrashReport; ofs << finalCrashReport;
ofs.close(); ofs.close();
Debug::disableStdout = false;
Debug::log(CRIT, "Hyprland has crashed :( Consult the crash report at %s for more information.", path.c_str());
} }