Old logs are now deleted when creating the logs folder inside the application data directory

This commit is contained in:
Leon Styhre 2023-12-16 13:17:13 +01:00
parent a0b4b006a7
commit 8887b9684c

View file

@ -385,8 +385,8 @@ bool parseArguments(const std::vector<std::string>& arguments)
Log::setReportingLevel(LogDebug); Log::setReportingLevel(LogDebug);
} }
else if (arguments[i] == "--version" || arguments[i] == "-v") { else if (arguments[i] == "--version" || arguments[i] == "-v") {
std::cout << "ES-DE v" << PROGRAM_VERSION_STRING << " (r" std::cout << "ES-DE v" << PROGRAM_VERSION_STRING << " (r" << PROGRAM_RELEASE_NUMBER
<< PROGRAM_RELEASE_NUMBER << ")\n"; << ")\n";
return false; return false;
} }
else if (arguments[i] == "--help" || arguments[i] == "-h") { else if (arguments[i] == "--help" || arguments[i] == "-h") {
@ -616,6 +616,13 @@ int main(int argc, char* argv[])
std::cerr << "Couldn't create directory, permission problems?" << std::endl; std::cerr << "Couldn't create directory, permission problems?" << std::endl;
#endif #endif
} }
else {
// Remove any old logs in the root of the directory.
Utils::FileSystem::removeFile(
Utils::FileSystem::getAppDataDirectory().append("es_log.txt").string());
Utils::FileSystem::removeFile(
Utils::FileSystem::getAppDataDirectory().append("es_log.txt.bak").string());
}
} }
} }
} }
@ -623,8 +630,8 @@ int main(int argc, char* argv[])
// Start the logger. // Start the logger.
Log::init(); Log::init();
Log::open(); Log::open();
LOG(LogInfo) << "ES-DE v" << PROGRAM_VERSION_STRING << " (r" LOG(LogInfo) << "ES-DE v" << PROGRAM_VERSION_STRING << " (r" << PROGRAM_RELEASE_NUMBER
<< PROGRAM_RELEASE_NUMBER << "), built " << PROGRAM_BUILT_STRING; << "), built " << PROGRAM_BUILT_STRING;
if (portableMode) { if (portableMode) {
LOG(LogInfo) << "Running in portable mode"; LOG(LogInfo) << "Running in portable mode";
Settings::getInstance()->setBool("PortableMode", true); Settings::getInstance()->setBool("PortableMode", true);