Fix logging started from shortcut
This commit is contained in:
+9
-5
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user