mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
added logs to fancy zones (#8190)
This commit is contained in:
@@ -10,6 +10,8 @@ struct LogSettings
|
|||||||
inline const static std::wstring runnerLogPath = L"RunnerLogs\\runner-log.txt";
|
inline const static std::wstring runnerLogPath = L"RunnerLogs\\runner-log.txt";
|
||||||
inline const static std::string launcherLoggerName = "launcher";
|
inline const static std::string launcherLoggerName = "launcher";
|
||||||
inline const static std::wstring launcherLogPath = L"LogsModuleInterface\\launcher-log.txt";
|
inline const static std::wstring launcherLogPath = L"LogsModuleInterface\\launcher-log.txt";
|
||||||
|
inline const static std::string fancyZonesLoggerName = "fancyzones";
|
||||||
|
inline const static std::wstring fancyZonesLogPath = L"FancyZonesLogs\\fancyzones-log.txt";
|
||||||
inline const static std::string shortcutGuideLoggerName = "shortcut-guide";
|
inline const static std::string shortcutGuideLoggerName = "shortcut-guide";
|
||||||
inline const static std::wstring shortcutGuideLogPath = L"ShortcutGuideLogs\\shortcut-guide-log.txt";
|
inline const static std::wstring shortcutGuideLogPath = L"ShortcutGuideLogs\\shortcut-guide-log.txt";
|
||||||
inline const static int retention = 30;
|
inline const static int retention = 30;
|
||||||
|
|||||||
@@ -119,6 +119,9 @@
|
|||||||
<ProjectReference Include="..\..\..\common\common.vcxproj">
|
<ProjectReference Include="..\..\..\common\common.vcxproj">
|
||||||
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
|
<Project>{74485049-c722-400f-abe5-86ac52d929b3}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">
|
||||||
|
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\lib\FancyZonesLib.vcxproj">
|
<ProjectReference Include="..\lib\FancyZonesLib.vcxproj">
|
||||||
<Project>{f9c68edf-ac74-4b77-9af1-005d9c9f6a99}</Project>
|
<Project>{f9c68edf-ac74-4b77-9af1-005d9c9f6a99}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
@@ -130,6 +133,7 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<Import Project="..\..\..\..\deps\spdlog.props" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <lib/FancyZonesData.h>
|
#include <lib/FancyZonesData.h>
|
||||||
#include <lib/FancyZonesWinHookEventIDs.h>
|
#include <lib/FancyZonesWinHookEventIDs.h>
|
||||||
#include <lib/FancyZonesData.cpp>
|
#include <lib/FancyZonesData.cpp>
|
||||||
|
#include <lib/FancyZonesLogger.h>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@@ -74,6 +75,8 @@ public:
|
|||||||
// Enable the powertoy
|
// Enable the powertoy
|
||||||
virtual void enable()
|
virtual void enable()
|
||||||
{
|
{
|
||||||
|
FancyZonesLogger::GetLogger()->info("FancyZones enabling");
|
||||||
|
|
||||||
if (!m_app)
|
if (!m_app)
|
||||||
{
|
{
|
||||||
InitializeWinhookEventIds();
|
InitializeWinhookEventIds();
|
||||||
@@ -130,6 +133,8 @@ public:
|
|||||||
// Disable the powertoy
|
// Disable the powertoy
|
||||||
virtual void disable()
|
virtual void disable()
|
||||||
{
|
{
|
||||||
|
FancyZonesLogger::GetLogger()->info("FancyZones disabling");
|
||||||
|
|
||||||
Disable(true);
|
Disable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +155,7 @@ public:
|
|||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
|
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
|
||||||
app_key = NonLocalizable::FancyZonesStr;
|
app_key = NonLocalizable::FancyZonesStr;
|
||||||
|
FancyZonesLogger::Init(PTSettingsHelper::get_module_save_folder_location(app_key));
|
||||||
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
|
m_settings = MakeFancyZonesSettings(reinterpret_cast<HINSTANCE>(&__ImageBase), FancyZonesModule::get_name(), FancyZonesModule::get_key());
|
||||||
FancyZonesDataInstance().LoadFancyZonesData();
|
FancyZonesDataInstance().LoadFancyZonesData();
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="FancyZonesLogger.h" />
|
||||||
<ClInclude Include="FancyZones.h" />
|
<ClInclude Include="FancyZones.h" />
|
||||||
<ClInclude Include="FancyZonesDataTypes.h" />
|
<ClInclude Include="FancyZonesDataTypes.h" />
|
||||||
<ClInclude Include="FancyZonesWinHookEventIDs.h" />
|
<ClInclude Include="FancyZonesWinHookEventIDs.h" />
|
||||||
@@ -128,6 +129,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="FancyZones.cpp" />
|
<ClCompile Include="FancyZones.cpp" />
|
||||||
<ClCompile Include="FancyZonesDataTypes.cpp" />
|
<ClCompile Include="FancyZonesDataTypes.cpp" />
|
||||||
|
<ClCompile Include="FancyZonesLogger.cpp" />
|
||||||
<ClCompile Include="FancyZonesWinHookEventIDs.cpp" />
|
<ClCompile Include="FancyZonesWinHookEventIDs.cpp" />
|
||||||
<ClCompile Include="FancyZonesData.cpp" />
|
<ClCompile Include="FancyZonesData.cpp" />
|
||||||
<ClCompile Include="JsonHelpers.cpp" />
|
<ClCompile Include="JsonHelpers.cpp" />
|
||||||
@@ -156,7 +158,13 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources.resx" />
|
<None Include="Resources.resx" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\..\common\logger\logger.vcxproj">
|
||||||
|
<Project>{d9b8fc84-322a-4f9f-bbb9-20915c47ddfd}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<Import Project="..\..\..\..\deps\spdlog.props" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
<Import Project="..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.200902.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
|
||||||
<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')" />
|
<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')" />
|
||||||
|
|||||||
24
src/modules/fancyzones/lib/FancyZonesLogger.cpp
Normal file
24
src/modules/fancyzones/lib/FancyZonesLogger.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include <common\settings_helpers.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include "FancyZonesLogger.h"
|
||||||
|
|
||||||
|
std::shared_ptr<Logger> FancyZonesLogger::logger;
|
||||||
|
|
||||||
|
void FancyZonesLogger::Init(std::wstring moduleSaveLocation)
|
||||||
|
{
|
||||||
|
std::filesystem::path logFilePath(moduleSaveLocation);
|
||||||
|
logFilePath.append(LogSettings::fancyZonesLogPath);
|
||||||
|
logger = std::make_shared<Logger>(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
||||||
|
logger->info("FancyZones logger initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Logger> FancyZonesLogger::GetLogger()
|
||||||
|
{
|
||||||
|
if (!logger)
|
||||||
|
{
|
||||||
|
throw "FancyZones logger is not initialized";
|
||||||
|
}
|
||||||
|
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
10
src/modules/fancyzones/lib/FancyZonesLogger.h
Normal file
10
src/modules/fancyzones/lib/FancyZonesLogger.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
|
class FancyZonesLogger
|
||||||
|
{
|
||||||
|
static std::shared_ptr<Logger> logger;
|
||||||
|
public:
|
||||||
|
static void Init(std::wstring moduleSaveLocation);
|
||||||
|
static std::shared_ptr<Logger> GetLogger();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user