mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-12 12:43:04 +08:00
Fix runner warnings (#8211)
This commit is contained in:
parent
7c9888300b
commit
f0553c370a
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@ -2501,6 +2501,7 @@ website
|
|||||||
webview
|
webview
|
||||||
wekyb
|
wekyb
|
||||||
wexfs
|
wexfs
|
||||||
|
wdupenv
|
||||||
Whichdoes
|
Whichdoes
|
||||||
whitespaces
|
whitespaces
|
||||||
WIC
|
WIC
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <spdlog/sinks/daily_file_sink.h>
|
#include <spdlog/sinks/daily_file_sink.h>
|
||||||
#include <spdlog\sinks\stdout_color_sinks-inl.h>
|
#include <spdlog\sinks\stdout_color_sinks-inl.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <spdlog\sinks\null_sink.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace spdlog;
|
using namespace spdlog;
|
||||||
@ -33,31 +34,45 @@ level::level_enum getLogLevel(std::wstring_view logSettingsPath)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Logger()
|
std::shared_ptr<spdlog::logger> Logger::logger;
|
||||||
|
|
||||||
|
bool Logger::wasLogFailedShown()
|
||||||
{
|
{
|
||||||
|
wchar_t* pValue;
|
||||||
|
size_t len;
|
||||||
|
_wdupenv_s(&pValue, &len, logFailedShown.c_str());
|
||||||
|
delete[] pValue;
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Logger(std::string loggerName, std::wstring logFilePath, std::wstring_view logSettingsPath)
|
void Logger::init(std::string loggerName, std::wstring logFilePath, std::wstring_view logSettingsPath)
|
||||||
{
|
{
|
||||||
auto logLevel = getLogLevel(logSettingsPath);
|
auto logLevel = getLogLevel(logSettingsPath);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto sink = make_shared<sinks::daily_file_sink_mt>(logFilePath, 0, 0, false, LogSettings::retention);
|
auto sink = make_shared<sinks::daily_file_sink_mt>(logFilePath, 0, 0, false, LogSettings::retention);
|
||||||
this->logger = make_shared<spdlog::logger>(loggerName, sink);
|
logger = make_shared<spdlog::logger>(loggerName, sink);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
cerr << "Can not create file logger. Create stdout logger instead" << endl;
|
logger = spdlog::null_logger_mt(loggerName);
|
||||||
this->logger = spdlog::stdout_color_mt("some_unique_name");
|
if (!wasLogFailedShown())
|
||||||
}
|
|
||||||
|
|
||||||
this->logger->set_level(logLevel);
|
|
||||||
this->logger->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [p-%P] [t-%t] [%l] %v");
|
|
||||||
spdlog::register_logger(this->logger);
|
|
||||||
spdlog::flush_every(std::chrono::seconds(3));
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::~Logger()
|
|
||||||
{
|
{
|
||||||
this->logger.reset();
|
// todo: that message should be shown from init caller and strings should be localized
|
||||||
|
MessageBoxW(NULL,
|
||||||
|
L"Logger can not be initialized",
|
||||||
|
L"PowerToys",
|
||||||
|
MB_OK | MB_ICONERROR);
|
||||||
|
|
||||||
|
SetEnvironmentVariable(logFailedShown.c_str(), L"yes");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger->set_level(logLevel);
|
||||||
|
logger->set_pattern("[%Y-%m-%d %H:%M:%S.%f] [p-%P] [t-%t] [%l] %v");
|
||||||
|
spdlog::register_logger(logger);
|
||||||
|
spdlog::flush_every(std::chrono::seconds(3));
|
||||||
|
logger->info("{} logger is initialized", loggerName);
|
||||||
}
|
}
|
||||||
|
@ -5,53 +5,54 @@
|
|||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<spdlog::logger> logger;
|
inline const static std::wstring logFailedShown = L"logFailedShown";
|
||||||
|
static std::shared_ptr<spdlog::logger> logger;
|
||||||
|
static bool wasLogFailedShown();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Logger();
|
Logger() = delete;
|
||||||
Logger(std::string loggerName, std::wstring logFilePath, std::wstring_view logSettingsPath);
|
|
||||||
|
static void init(std::string loggerName, std::wstring logFilePath, std::wstring_view logSettingsPath);
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void trace(const FormatString& fmt, const Args&... args)
|
static void trace(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->trace(fmt, args...);
|
logger->trace(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void debug(const FormatString& fmt, const Args&... args)
|
static void debug(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->debug(fmt, args...);
|
logger->debug(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void info(const FormatString& fmt, const Args&... args)
|
static void info(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->info(fmt, args...);
|
logger->info(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void warn(const FormatString& fmt, const Args&... args)
|
static void warn(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->warn(fmt, args...);
|
logger->warn(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void error(const FormatString& fmt, const Args&... args)
|
static void error(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->error(fmt, args...);
|
logger->error(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// log message should not be localized
|
// log message should not be localized
|
||||||
template<typename FormatString, typename... Args>
|
template<typename FormatString, typename... Args>
|
||||||
void critical(const FormatString& fmt, const Args&... args)
|
static void critical(const FormatString& fmt, const Args&... args)
|
||||||
{
|
{
|
||||||
this->logger->critical(fmt, args...);
|
logger->critical(fmt, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Logger();
|
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,6 @@ void to_file(std::wstring_view file_name, const JsonObject& obj)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << "Can not create log config file" << std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ LogSettings to_settings(JsonObject jobject)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr << "Can not read log level from config file" << std::endl;
|
|
||||||
result.logLevel = LogSettings::defaultLogLevel;
|
result.logLevel = LogSettings::defaultLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace timeutil
|
|||||||
|
|
||||||
inline int64_t in_days(const std::time_t to, const std::time_t from)
|
inline int64_t in_days(const std::time_t to, const std::time_t from)
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>(std::difftime(to, from) / (3600 * 24));
|
return static_cast<int64_t>(std::difftime(to, from) / (3600 * (int64_t)24));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ namespace UnitTest_ColorPickerUI.Helpers
|
|||||||
{
|
{
|
||||||
var color = Color.FromArgb(red, green, blue);
|
var color = Color.FromArgb(red, green, blue);
|
||||||
|
|
||||||
Exception exception = null;
|
Exception? exception = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -13,7 +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>
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public:
|
|||||||
// Enable the powertoy
|
// Enable the powertoy
|
||||||
virtual void enable()
|
virtual void enable()
|
||||||
{
|
{
|
||||||
FancyZonesLogger::GetLogger()->info("FancyZones enabling");
|
Logger::info("FancyZones enabling");
|
||||||
|
|
||||||
if (!m_app)
|
if (!m_app)
|
||||||
{
|
{
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
// Disable the powertoy
|
// Disable the powertoy
|
||||||
virtual void disable()
|
virtual void disable()
|
||||||
{
|
{
|
||||||
FancyZonesLogger::GetLogger()->info("FancyZones disabling");
|
Logger::info("FancyZones disabling");
|
||||||
|
|
||||||
Disable(true);
|
Disable(true);
|
||||||
}
|
}
|
||||||
@ -155,7 +155,9 @@ 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));
|
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
|
||||||
|
logFilePath.append(LogSettings::fancyZonesLogPath);
|
||||||
|
Logger::init(LogSettings::fancyZonesLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
||||||
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;
|
||||||
|
@ -102,7 +102,6 @@
|
|||||||
</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,7 +127,6 @@
|
|||||||
<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" />
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
#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();
|
|
||||||
};
|
|
@ -78,8 +78,6 @@ private:
|
|||||||
// Handle to event used to invoke the Runner
|
// Handle to event used to invoke the Runner
|
||||||
HANDLE m_hEvent;
|
HANDLE m_hEvent;
|
||||||
|
|
||||||
std::shared_ptr<Logger> logger;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Microsoft_Launcher()
|
Microsoft_Launcher()
|
||||||
@ -88,8 +86,8 @@ public:
|
|||||||
app_key = LauncherConstants::ModuleKey;
|
app_key = LauncherConstants::ModuleKey;
|
||||||
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(this->app_key));
|
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(this->app_key));
|
||||||
logFilePath.append(LogSettings::launcherLogPath);
|
logFilePath.append(LogSettings::launcherLogPath);
|
||||||
logger = std::make_shared<Logger>(LogSettings::launcherLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
Logger::init(LogSettings::launcherLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
||||||
logger->info("Launcher object is constructing");
|
Logger::info("Launcher object is constructing");
|
||||||
init_settings();
|
init_settings();
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
@ -101,8 +99,7 @@ public:
|
|||||||
|
|
||||||
~Microsoft_Launcher()
|
~Microsoft_Launcher()
|
||||||
{
|
{
|
||||||
logger->info("Launcher object is destroying");
|
Logger::info("Launcher object is destroying");
|
||||||
logger.reset();
|
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
terminateProcess();
|
terminateProcess();
|
||||||
@ -183,7 +180,7 @@ public:
|
|||||||
// Enable the powertoy
|
// Enable the powertoy
|
||||||
virtual void enable()
|
virtual void enable()
|
||||||
{
|
{
|
||||||
this->logger->info("Launcher is enabling");
|
Logger::info("Launcher is enabling");
|
||||||
ResetEvent(m_hEvent);
|
ResetEvent(m_hEvent);
|
||||||
// Start PowerLauncher.exe only if the OS is 19H1 or higher
|
// Start PowerLauncher.exe only if the OS is 19H1 or higher
|
||||||
if (UseNewSettings())
|
if (UseNewSettings())
|
||||||
@ -255,7 +252,7 @@ public:
|
|||||||
// Disable the powertoy
|
// Disable the powertoy
|
||||||
virtual void disable()
|
virtual void disable()
|
||||||
{
|
{
|
||||||
this->logger->info("Launcher is disabling");
|
Logger::info("Launcher is disabling");
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
ResetEvent(m_hEvent);
|
ResetEvent(m_hEvent);
|
||||||
@ -327,7 +324,7 @@ public:
|
|||||||
if (TerminateProcess(m_hProcess, 1) == 0)
|
if (TerminateProcess(m_hProcess, 1) == 0)
|
||||||
{
|
{
|
||||||
auto err = get_last_error_message(GetLastError());
|
auto err = get_last_error_message(GetLastError());
|
||||||
this->logger->error(L"Launcher process was not terminated. {}", err.has_value() ? err.value() : L"");
|
Logger::error(L"Launcher process was not terminated. {}", err.has_value() ? err.value() : L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporarily disable sending a message to close
|
// Temporarily disable sending a message to close
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
#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();
|
|
||||||
};
|
|
@ -7,9 +7,11 @@
|
|||||||
#include <common/settings_objects.h>
|
#include <common/settings_objects.h>
|
||||||
#include <common/debug_control.h>
|
#include <common/debug_control.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <modules\shortcut_guide\ShortcutGuideConstants.h>
|
#include <modules/shortcut_guide/ShortcutGuideConstants.h>
|
||||||
#include <modules\shortcut_guide\ShortcutGuideLogger.h>
|
|
||||||
#include <common\settings_helpers.cpp>
|
#include <common/settings_helpers.cpp>
|
||||||
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
|
|
||||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||||
|
|
||||||
@ -98,8 +100,10 @@ OverlayWindow::OverlayWindow()
|
|||||||
{
|
{
|
||||||
app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE);
|
app_name = GET_RESOURCE_STRING(IDS_SHORTCUT_GUIDE);
|
||||||
app_key = ShortcutGuideConstants::ModuleKey;
|
app_key = ShortcutGuideConstants::ModuleKey;
|
||||||
ShortcutGuideLogger::Init(PTSettingsHelper::get_module_save_folder_location(app_key));
|
std::filesystem::path logFilePath(PTSettingsHelper::get_module_save_folder_location(app_key));
|
||||||
ShortcutGuideLogger::GetLogger()->info("Overlay Window is creating");
|
logFilePath.append(LogSettings::shortcutGuideLogPath);
|
||||||
|
Logger::init(LogSettings::shortcutGuideLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
||||||
|
Logger::info("Overlay Window is creating");
|
||||||
init_settings();
|
init_settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +204,7 @@ constexpr UINT alternative_switch_vk_code = VK_OEM_2;
|
|||||||
|
|
||||||
void OverlayWindow::enable()
|
void OverlayWindow::enable()
|
||||||
{
|
{
|
||||||
ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is enabling");
|
Logger::info("Shortcut Guide is enabling");
|
||||||
|
|
||||||
auto switcher = [&](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
auto switcher = [&](HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||||
if (msg == WM_KEYDOWN && wparam == VK_ESCAPE && instance->target_state->active())
|
if (msg == WM_KEYDOWN && wparam == VK_ESCAPE && instance->target_state->active())
|
||||||
@ -253,7 +257,7 @@ void OverlayWindow::enable()
|
|||||||
|
|
||||||
void OverlayWindow::disable(bool trace_event)
|
void OverlayWindow::disable(bool trace_event)
|
||||||
{
|
{
|
||||||
ShortcutGuideLogger::GetLogger()->info("Shortcut Guide is disabling");
|
Logger::info("Shortcut Guide is disabling");
|
||||||
|
|
||||||
if (_enabled)
|
if (_enabled)
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,6 @@
|
|||||||
<ClInclude Include="Generated Files/resource.h" />
|
<ClInclude Include="Generated Files/resource.h" />
|
||||||
<None Include="resource.base.h" />
|
<None Include="resource.base.h" />
|
||||||
<ClInclude Include="ShortcutGuideConstants.h" />
|
<ClInclude Include="ShortcutGuideConstants.h" />
|
||||||
<ClInclude Include="ShortcutGuideLogger.h" />
|
|
||||||
<ClInclude Include="shortcut_guide.h" />
|
<ClInclude Include="shortcut_guide.h" />
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
<ClInclude Include="target_state.h" />
|
<ClInclude Include="target_state.h" />
|
||||||
@ -125,7 +124,6 @@
|
|||||||
<ClCompile Include="overlay_window.cpp" />
|
<ClCompile Include="overlay_window.cpp" />
|
||||||
<ClCompile Include="dllmain.cpp" />
|
<ClCompile Include="dllmain.cpp" />
|
||||||
<ClCompile Include="keyboard_state.cpp" />
|
<ClCompile Include="keyboard_state.cpp" />
|
||||||
<ClCompile Include="ShortcutGuideLogger.cpp" />
|
|
||||||
<ClCompile Include="shortcut_guide.cpp" />
|
<ClCompile Include="shortcut_guide.cpp" />
|
||||||
<ClCompile Include="pch.cpp">
|
<ClCompile Include="pch.cpp">
|
||||||
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(CIBuild)'!='true'">Create</PrecompiledHeader>
|
||||||
|
@ -46,7 +46,6 @@ namespace
|
|||||||
const wchar_t POWER_TOYS_MODULE_LOAD_FAIL[] = L"Failed to load "; // Module name will be appended on this message and it is not localized.
|
const wchar_t POWER_TOYS_MODULE_LOAD_FAIL[] = L"Failed to load "; // Module name will be appended on this message and it is not localized.
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Logger> logger;
|
|
||||||
void chdir_current_executable()
|
void chdir_current_executable()
|
||||||
{
|
{
|
||||||
// Change current directory to the path of the executable.
|
// Change current directory to the path of the executable.
|
||||||
@ -77,7 +76,11 @@ void open_menu_from_another_instance()
|
|||||||
|
|
||||||
int runner(bool isProcessElevated)
|
int runner(bool isProcessElevated)
|
||||||
{
|
{
|
||||||
logger->info("Runner is starting. Elevated={}", isProcessElevated);
|
std::filesystem::path logFilePath(PTSettingsHelper::get_root_save_folder_location());
|
||||||
|
logFilePath.append(LogSettings::runnerLogPath);
|
||||||
|
Logger::init(LogSettings::runnerLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
||||||
|
|
||||||
|
Logger::info("Runner is starting. Elevated={}", isProcessElevated);
|
||||||
DPIAware::EnableDPIAwarenessForThisProcess();
|
DPIAware::EnableDPIAwarenessForThisProcess();
|
||||||
|
|
||||||
#if _DEBUG && _WIN64
|
#if _DEBUG && _WIN64
|
||||||
@ -296,10 +299,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::path logFilePath(PTSettingsHelper::get_root_save_folder_location());
|
|
||||||
logFilePath = logFilePath.append(LogSettings::runnerLogPath);
|
|
||||||
logger = std::make_shared<Logger>(LogSettings::runnerLoggerName, logFilePath.wstring(), PTSettingsHelper::get_log_settings_file_location());
|
|
||||||
|
|
||||||
int n_cmd_args = 0;
|
int n_cmd_args = 0;
|
||||||
LPWSTR* cmd_arg_list = CommandLineToArgvW(GetCommandLineW(), &n_cmd_args);
|
LPWSTR* cmd_arg_list = CommandLineToArgvW(GetCommandLineW(), &n_cmd_args);
|
||||||
switch (should_run_in_special_mode(n_cmd_args, cmd_arg_list))
|
switch (should_run_in_special_mode(n_cmd_args, cmd_arg_list))
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <common/os-detect.h>
|
#include <common/os-detect.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <common/VersionHelper.h>
|
#include <common/VersionHelper.h>
|
||||||
|
#include <common/logger/logger.h>
|
||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
|
|
||||||
@ -276,9 +277,18 @@ void run_settings_window()
|
|||||||
std::wstring powertoys_pipe_name(L"\\\\.\\pipe\\powertoys_runner_");
|
std::wstring powertoys_pipe_name(L"\\\\.\\pipe\\powertoys_runner_");
|
||||||
std::wstring settings_pipe_name(L"\\\\.\\pipe\\powertoys_settings_");
|
std::wstring settings_pipe_name(L"\\\\.\\pipe\\powertoys_settings_");
|
||||||
UUID temp_uuid;
|
UUID temp_uuid;
|
||||||
UuidCreate(&temp_uuid);
|
wchar_t* uuid_chars = nullptr;
|
||||||
wchar_t* uuid_chars;
|
if (UuidCreate(&temp_uuid) == RPC_S_UUID_NO_ADDRESS)
|
||||||
UuidToString(&temp_uuid, (RPC_WSTR*)&uuid_chars);
|
{
|
||||||
|
auto val = get_last_error_message(GetLastError());
|
||||||
|
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
||||||
|
}
|
||||||
|
else if (UuidToString(&temp_uuid, (RPC_WSTR*)&uuid_chars) != RPC_S_OK)
|
||||||
|
{
|
||||||
|
auto val = get_last_error_message(GetLastError());
|
||||||
|
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
||||||
|
}
|
||||||
|
|
||||||
if (uuid_chars != nullptr)
|
if (uuid_chars != nullptr)
|
||||||
{
|
{
|
||||||
powertoys_pipe_name += std::wstring(uuid_chars);
|
powertoys_pipe_name += std::wstring(uuid_chars);
|
||||||
@ -386,11 +396,19 @@ void run_settings_window()
|
|||||||
current_settings_ipc->start(hToken);
|
current_settings_ipc->start(hToken);
|
||||||
g_settings_process_id = process_info.dwProcessId;
|
g_settings_process_id = process_info.dwProcessId;
|
||||||
|
|
||||||
|
if (process_info.hProcess)
|
||||||
|
{
|
||||||
WaitForSingleObject(process_info.hProcess, INFINITE);
|
WaitForSingleObject(process_info.hProcess, INFINITE);
|
||||||
if (WaitForSingleObject(process_info.hProcess, INFINITE) != WAIT_OBJECT_0)
|
if (WaitForSingleObject(process_info.hProcess, INFINITE) != WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
show_last_error_message(L"Couldn't wait on the Settings Window to close.", GetLastError(), L"PowerToys - runner");
|
show_last_error_message(L"Couldn't wait on the Settings Window to close.", GetLastError(), L"PowerToys - runner");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto val = get_last_error_message(GetLastError());
|
||||||
|
Logger::error(L"Process handle is empty. {}", val.has_value() ? val.value() : L"");
|
||||||
|
}
|
||||||
|
|
||||||
LExit:
|
LExit:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user