[Log] Remove log_settings.json during installation and set default level to trace (#10438)

This commit is contained in:
Andrey Nekrasov 2021-03-25 17:28:29 +03:00 committed by GitHub
parent 718289c115
commit aac479f58c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 2 deletions

View File

@ -12,6 +12,7 @@
#include <common/utils/resources.h>
#include <common/utils/window.h>
#include <common/utils/winapi_error.h>
#include <common/SettingsAPI/settings_helpers.h>
#include <runner/action_runner_utils.h>
@ -79,6 +80,27 @@ void SetupLogger(fs::path directory, const spdlog::level::level_enum severity)
}
}
void CleanupSettingsFromOlderVersions()
{
try
{
const auto logSettingsFile = fs::path{ PTSettingsHelper::get_root_save_folder_location() } / PTSettingsHelper::log_settings_filename;
if (fs::is_regular_file(logSettingsFile))
{
fs::remove(logSettingsFile);
spdlog::info("Removed old log settings file");
}
else
{
spdlog::info("Old log settings file wasn't found");
}
}
catch(...)
{
spdlog::error("Failed to cleanup old log settings");
}
}
void ShowMessageBoxError(const wchar_t* message)
{
if (!g_Silent)
@ -380,6 +402,8 @@ int Bootstrapper(HINSTANCE hInstance)
ShowMessageBoxError(IDS_DOTNET_INSTALL_ERROR);
}
CleanupSettingsFromOlderVersions();
// At this point, there's no reason to show progress bar window, since MSI installers have their own
CloseProgressBarDialog();

View File

@ -4,7 +4,6 @@
namespace PTSettingsHelper
{
constexpr inline const wchar_t* settings_filename = L"\\settings.json";
constexpr inline const wchar_t* log_settings_filename = L"log_settings.json";
constexpr inline const wchar_t* oobe_filename = L"oobe_settings.json";
std::wstring get_root_save_folder_location()

View File

@ -6,6 +6,8 @@
namespace PTSettingsHelper
{
constexpr inline const wchar_t* log_settings_filename = L"log_settings.json";
std::wstring get_module_save_folder_location(std::wstring_view powertoy_name);
std::wstring get_root_save_folder_location();

View File

@ -4,7 +4,7 @@
struct LogSettings
{
// The following strings are not localizable
inline const static std::wstring defaultLogLevel = L"warn";
inline const static std::wstring defaultLogLevel = L"trace";
inline const static std::wstring logLevelOption = L"logLevel";
inline const static std::string runnerLoggerName = "runner";
inline const static std::wstring runnerLogPath = L"RunnerLogs\\runner-log.txt";