Skip to content

Commit

Permalink
logs (#10462)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykhailopylyp committed Mar 26, 2021
1 parent 5baf11d commit 9a3896f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/modules/launcher/Microsoft.Launcher/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ class Microsoft_Launcher : public PowertoyModuleIface
void terminateProcess()
{
Logger::trace(L"Terminating PowerToys Run process. Handle {}.", m_hProcess);
if (WaitForSingleObject(m_hProcess, 0) == WAIT_OBJECT_0)
{
Logger::warn("PowerToys Run has exited unexpectedly, so there is no need to terminate it.");
return;
}

DWORD processID = GetProcessId(m_hProcess);
if (TerminateProcess(m_hProcess, 1) == 0)
{
Expand Down
3 changes: 3 additions & 0 deletions src/runner/centralized_kb_hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "centralized_kb_hook.h"
#include <common/debug_control.h>
#include <common/utils/winapi_error.h>
#include <common/logger/logger.h>

namespace CentralizedKeyboardHook
{
Expand Down Expand Up @@ -79,12 +80,14 @@ namespace CentralizedKeyboardHook

void SetHotkeyAction(const std::wstring& moduleName, const Hotkey& hotkey, std::function<bool()>&& action) noexcept
{
Logger::trace(L"Register hotkey action for {}", moduleName);
std::unique_lock lock{ mutex };
hotkeyDescriptors.insert({ .hotkey = hotkey, .moduleName = moduleName, .action = std::move(action) });
}

void ClearModuleHotkeys(const std::wstring& moduleName) noexcept
{
Logger::trace(L"UnRegister hotkey action for {}", moduleName);
std::unique_lock lock{ mutex };
auto it = hotkeyDescriptors.begin();
while (it != hotkeyDescriptors.end())
Expand Down
2 changes: 2 additions & 0 deletions src/runner/powertoy_module.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pch.h"
#include "powertoy_module.h"
#include "centralized_kb_hook.h"
#include <common/logger/logger.h>

std::map<std::wstring, PowertoyModule>& modules()
{
Expand Down Expand Up @@ -60,6 +61,7 @@ void PowertoyModule::update_hotkeys()
for (size_t i = 0; i < hotkeyCount; i++)
{
CentralizedKeyboardHook::SetHotkeyAction(pt_module->get_key(), hotkeys[i], [modulePtr, i] {
Logger::trace(L"{} hotkey is invoked from Centralized keyboard hook", modulePtr->get_key());
return modulePtr->on_hotkey(i);
});
}
Expand Down

0 comments on commit 9a3896f

Please sign in to comment.