Fix logging started from shortcut

This commit is contained in:
Yukino Song
2025-04-01 23:08:31 +08:00
parent 535a89b2ec
commit b8e614a315
+9 -5
View File
@@ -108,12 +108,16 @@ namespace logging {
// Check if the log file exists and handle backup // Check if the log file exists and handle backup
std::string backup_log_file = log_file + ".backup"; std::string backup_log_file = log_file + ".backup";
if (std::filesystem::exists(log_file)) { if (std::filesystem::exists(log_file)) {
// If the backup file exists, remove it try {
if (std::filesystem::exists(backup_log_file)) { // If the backup file exists, remove it
std::filesystem::remove(backup_log_file); if (std::filesystem::exists(backup_log_file)) {
std::filesystem::remove(backup_log_file);
}
// Rename the current log file to the backup name
std::filesystem::rename(log_file, backup_log_file);
} catch (std::exception& e) {
std::cout << "Failed to rotate log file: " << e.what() << std::endl;
} }
// Rename the current log file to the backup name
std::filesystem::rename(log_file, backup_log_file);
} }
setup_av_logging(min_log_level); setup_av_logging(min_log_level);