Skip to content

Commit

Permalink
LOG: when retrodeck is defined just open the logfile in append mode a…
Browse files Browse the repository at this point in the history
…nd void backing up
  • Loading branch information
XargonWan committed Nov 30, 2024
1 parent fa2d75a commit f64cbe8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions es-core/src/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,33 @@ void Log::init()
// Default to the existing location if rd_logs_folder is not defined
sLogPath = Utils::FileSystem::getAppDataDirectory() + "/retrodeck.log";
}
// Skip renaming to .bak for RetroDECK
#else
if (Settings::getInstance()->getBool("LegacyAppDataDirectory"))
sLogPath = Utils::FileSystem::getAppDataDirectory() + "/es_log.txt";
else
sLogPath = Utils::FileSystem::getAppDataDirectory() + "/logs/es_log.txt";
#endif

Utils::FileSystem::removeFile(sLogPath + ".bak");
// Rename the previous log file.
Utils::FileSystem::renameFile(sLogPath, sLogPath + ".bak", true);
return;
#endif
}

void Log::open()
{
std::unique_lock<std::mutex> lock {sLogMutex};

std::ios_base::openmode mode = std::ios::out;
#if defined(RETRODECK)
mode |= std::ios::app; // Append to the log file if RetroDECK is defined
#endif

#if defined(_WIN64)
sFile.open(Utils::String::stringToWideString(sLogPath).c_str());
sFile.open(Utils::String::stringToWideString(sLogPath).c_str(), mode);
#else
sFile.open(sLogPath.c_str());
sFile.open(sLogPath.c_str(), mode);
#endif
}

Expand Down

0 comments on commit f64cbe8

Please sign in to comment.