diff --git a/src/common/logger/logger_settings.h b/src/common/logger/logger_settings.h index dd131fc524..ea47bdfef4 100644 --- a/src/common/logger/logger_settings.h +++ b/src/common/logger/logger_settings.h @@ -10,6 +10,8 @@ struct LogSettings inline const static std::wstring runnerLogPath = L"RunnerLogs\\runner-log.txt"; inline const static std::string launcherLoggerName = "launcher"; inline const static std::wstring launcherLogPath = L"LogsModuleInterface\\launcher-log.txt"; + inline const static std::string shortcutGuideLoggerName = "shortcut-guide"; + inline const static std::wstring shortcutGuideLogPath = L"ShortcutGuideLogs\\shortcut-guide-log.txt"; inline const static int retention = 30; std::wstring logLevel; LogSettings(); diff --git a/src/modules/shortcut_guide/ShortcutGuideLogger.cpp b/src/modules/shortcut_guide/ShortcutGuideLogger.cpp new file mode 100644 index 0000000000..72f7fb7e67 --- /dev/null +++ b/src/modules/shortcut_guide/ShortcutGuideLogger.cpp @@ -0,0 +1,24 @@ +#include "pch.h" +#include "ShortcutGuideLogger.h" +#include +#include + +std::shared_ptr ShortcutGuideLogger::logger; + +void ShortcutGuideLogger::Init(std::wstring moduleSaveLocation) +{ + std::filesystem::path logFilePath(moduleSaveLocation); + logFilePath.append(LogSettings::shortcutGuideLogPath); + logger = std::make_shared(LogSettings::shortcutGuideLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location()); + logger->info("Shortcut Guide logger initialized"); +} + +std::shared_ptr ShortcutGuideLogger::GetLogger() +{ + if (!logger) + { + throw "Shortcut Guide logger is not initialized"; + } + + return logger; +} diff --git a/src/modules/shortcut_guide/ShortcutGuideLogger.h b/src/modules/shortcut_guide/ShortcutGuideLogger.h new file mode 100644 index 0000000000..9703ca0f66 --- /dev/null +++ b/src/modules/shortcut_guide/ShortcutGuideLogger.h @@ -0,0 +1,11 @@ +#pragma once +#include + +class ShortcutGuideLogger +{ + static std::shared_ptr logger; + +public: + static void Init(std::wstring moduleSaveLocation); + static std::shared_ptr GetLogger(); +}; \ No newline at end of file diff --git a/src/modules/shortcut_guide/shortcut_guide.cpp b/src/modules/shortcut_guide/shortcut_guide.cpp index d51cfa0090..03226c3e03 100644 --- a/src/modules/shortcut_guide/shortcut_guide.cpp +++ b/src/modules/shortcut_guide/shortcut_guide.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include extern "C" IMAGE_DOS_HEADER __ImageBase; @@ -96,6 +98,8 @@ OverlayWindow::OverlayWindow() { app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE); app_key = ShortcutGuideConstants::ModuleKey; + ShortcutGuideLogger::Init(PTSettingsHelper::get_module_save_folder_location(app_key)); + ShortcutGuideLogger::GetLogger()->info("Overlay Window is creating"); init_settings(); } @@ -196,6 +200,8 @@ constexpr UINT alternative_switch_vk_code = VK_OEM_2; void OverlayWindow::enable() { + ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is enabling"); + auto switcher = [&](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT { if (msg == WM_KEYDOWN && wparam == VK_ESCAPE && instance->target_state->active()) { @@ -247,6 +253,8 @@ void OverlayWindow::enable() void OverlayWindow::disable(bool trace_event) { + ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is disabling"); + if (_enabled) { _enabled = false; diff --git a/src/modules/shortcut_guide/shortcut_guide.vcxproj b/src/modules/shortcut_guide/shortcut_guide.vcxproj index 3bd8dc92cc..2ea6b9cda8 100644 --- a/src/modules/shortcut_guide/shortcut_guide.vcxproj +++ b/src/modules/shortcut_guide/shortcut_guide.vcxproj @@ -113,6 +113,7 @@ + @@ -125,6 +126,7 @@ + Create @@ -136,6 +138,9 @@ {74485049-c722-400f-abe5-86ac52d929b3} + + {d9b8fc84-322a-4f9f-bbb9-20915c47ddfd} + @@ -148,6 +153,7 @@ +