[FancyZones] Place log files in subfolders with the version number. (#10549)

This commit is contained in:
Seraphima Zykova
2021-04-07 14:43:35 +01:00
committed by GitHub
parent 675ae91c29
commit 55a851e5f2
4 changed files with 71 additions and 2 deletions

View File

@@ -14,6 +14,7 @@
#include <lib/FancyZonesWinHookEventIDs.h>
#include <lib/FancyZonesData.cpp>
#include <common/logger/logger.h>
#include <common/utils/logger_helper.h>
#include <common/utils/resources.h>
#include <common/utils/winapi_error.h>
#include <common/utils/window.h>
@@ -156,9 +157,19 @@ public:
{
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
app_key = NonLocalizable::FancyZonesStr;
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
const auto appFolder = PTSettingsHelper::get_module_save_folder_location(app_key);
const std::filesystem::path logFolder = LoggerHelpers::get_log_folder_path(appFolder);
std::filesystem::path logFilePath(logFolder);
logFilePath.append(LogSettings::fancyZonesLogPath);
Logger::init(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
std::filesystem::path oldLogFolder(appFolder);
oldLogFolder.append(LogSettings::fancyZonesOldLogPath);
LoggerHelpers::delete_old_log_folder(oldLogFolder);
LoggerHelpers::delete_other_versions_log_folders(appFolder, logFolder);
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
FancyZonesDataInstance().LoadFancyZonesData();
s_instance = this;