shortcut guide logs (#8191)

This commit is contained in:
Mykhailo Pylyp
2020-11-24 20:36:04 +02:00
committed by GitHub
parent 50dcd97611
commit 65f8966247
5 changed files with 51 additions and 0 deletions

View File

@@ -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();

View File

@@ -0,0 +1,24 @@
#include "pch.h"
#include "ShortcutGuideLogger.h"
#include <common\settings_helpers.h>
#include <filesystem>
std::shared_ptr<Logger> ShortcutGuideLogger::logger;
void ShortcutGuideLogger::Init(std::wstring moduleSaveLocation)
{
std::filesystem::path logFilePath(moduleSaveLocation);
logFilePath.append(LogSettings::shortcutGuideLogPath);
logger = std::make_shared<Logger>(LogSettings::shortcutGuideLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
logger->info("Shortcut Guide logger initialized");
}
std::shared_ptr<Logger> ShortcutGuideLogger::GetLogger()
{
if (!logger)
{
throw "Shortcut Guide logger is not initialized";
}
return logger;
}

View File

@@ -0,0 +1,11 @@
#pragma once
#include <common/logger/logger.h>
class ShortcutGuideLogger
{
static std::shared_ptr<Logger> logger;
public:
static void Init(std::wstring moduleSaveLocation);
static std::shared_ptr<Logger> GetLogger();
};

View File

@@ -8,6 +8,8 @@
#include <common/debug_control.h>
#include <sstream>
#include <modules\shortcut_guide\ShortcutGuideConstants.h>
#include <modules\shortcut_guide\ShortcutGuideLogger.h>
#include <common\settings_helpers.cpp>
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;

View File

@@ -113,6 +113,7 @@
<ClInclude Include="Generated Files/resource.h" />
<None Include="resource.base.h" />
<ClInclude Include="ShortcutGuideConstants.h" />
<ClInclude Include="ShortcutGuideLogger.h" />
<ClInclude Include="shortcut_guide.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="target_state.h" />
@@ -125,6 +126,7 @@
<ClCompile Include="overlay_window.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="keyboard_state.cpp" />
<ClCompile Include="ShortcutGuideLogger.cpp" />
<ClCompile Include="shortcut_guide.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>
@@ -136,6 +138,9 @@
<ProjectReference Include="..\..\common\common.vcxproj">
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
</ProjectReference>
<ProjectReference Include="..\..\common\logger\logger.vcxproj">
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Generated Files/shortcut_guide.rc" />
@@ -148,6 +153,7 @@
<None Include="Resources.resx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="..\..\..\deps\spdlog.props" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>