diff --git a/src/common/logging.cpp b/src/common/logging.cpp index b5def28e4d..f51726da42 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -247,6 +247,12 @@ struct ColorConsoleBackend final : public Backend { /// @brief Backend that writes to a file passed into the constructor struct FileBackend final : public Backend { explicit FileBackend(const std::filesystem::path& filename) noexcept { + auto old_filename = filename; + old_filename += ".old.txt"; + // Existence checks are done within the functions themselves. + // We don't particularly care if these succeed or not. + void(FS::RemoveFile(old_filename)); + void(FS::RenameFile(filename, old_filename)); file.emplace(filename, FS::FileAccessMode::Write, FS::FileType::TextFile); } ~FileBackend() noexcept override = default;