Emulator: Create a Log Backup

This commit is contained in:
Xphalnos 2025-02-17 14:51:45 +01:00
parent b06790dfe5
commit 8ddc545592

View File

@ -44,12 +44,21 @@ Frontend::WindowSDL* g_window = nullptr;
namespace Core { namespace Core {
Emulator::Emulator() { Emulator::Emulator() {
// Initialize NT API functions and set high priority // Initialize NT API functions and set high priority.
#ifdef _WIN32 #ifdef _WIN32
Common::NtApi::Initialize(); Common::NtApi::Initialize();
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
#endif #endif
// Renaming shad_log.txt to shad_log.old.txt when booting.
const auto LogDir = Common::FS::GetUserPath(Common::FS::PathType::LogDir);
const auto CurrentLog = LogDir / "shad_log.txt";
const auto NewLogName = LogDir / "shad_log.old.txt";
// Avoid crash due to shad_log.txt not existing.
if (std::filesystem::exists(CurrentLog)) {
rename(CurrentLog, NewLogName);
}
// Start logger. // Start logger.
Common::Log::Initialize(); Common::Log::Initialize();
Common::Log::Start(); Common::Log::Start();