Skip to content

Commit

Permalink
add debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
Apache553 committed Dec 10, 2023
1 parent 6ee1141 commit f02fed5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions SharedIncludes/EventLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ namespace sfh
void LogDebugMessage(const wchar_t* fmt, ...);
};
}

#define LOGDEBUG(fmt, ...) sfh::EventLog::GetInstance().LogDebugMessage((fmt), __VA_ARGS__)
11 changes: 10 additions & 1 deletion SubtitleFontAutoLoaderDaemon/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <shellapi.h>
#include <wil/win32_helpers.h>

#include "event.h"
#include "EventLog.h"

namespace sfh
{
Expand Down Expand Up @@ -152,6 +152,8 @@ namespace sfh
selfPath.remove_filename();
auto configPath = selfPath / L"SubtitleFontHelper.xml";
auto lruCachePath = selfPath / L"lruCache.txt";
LOGDEBUG(L"config Path = %ls", configPath.c_str());
LOGDEBUG(L"lruCache Path = %ls", lruCachePath.c_str());
auto cfg = ConfigFile::ReadFromFile(configPath);

m_service->m_systemTray = std::make_unique<SystemTray>(this);
Expand Down Expand Up @@ -214,12 +216,19 @@ int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm
setlocale(LC_ALL, "");
SetEnvironmentVariableW(L"__NO_DETOUR", L"TRUE");
auto cmdline = sfh::GetCommandLineVector(GetCommandLineW());
LOGDEBUG(L"Started with command line: %ls", GetCommandLineW());
sfh::ProcessCommandLine(cmdline);
try
{
sfh::SingleInstanceLock lock;
return sfh::Daemon().DaemonMain(cmdline);
}
catch (wil::ResultException& e)
{
wchar_t buffer[4096];
wil::GetFailureLogString(buffer, 4096, e.GetFailureInfo());
MessageBoxW(nullptr, buffer, L"Error", MB_OK | MB_ICONERROR);
}
catch (std::exception& e)
{
MessageBoxA(nullptr, e.what(), "Error", MB_OK | MB_ICONERROR);
Expand Down
3 changes: 2 additions & 1 deletion event.man
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
level="win:Informational" template="DllLoadFontTemplate"
message="$(string.SubtitleFontHelper.event.DllLoadFont)" />
<event symbol="DebugLog" value="10" version="0" channel="SubtitleFontHelper"
level="win:Verbose" template="LogTemplate" />
level="win:Verbose" template="LogTemplate" message="$(string.SubtitleFontHelper.event.DebugLog)"/>
</events>
<channels>
<channel
Expand Down Expand Up @@ -108,6 +108,7 @@
<string id="SubtitleFontHelper.event.DllQueryNoResult"
value="Query succeeded. pid: %1, tid: %2 requestName: %3 No font available." />
<string id="SubtitleFontHelper.event.DllLoadFont" value="pid: %1, tid: %2 load font file: %3" />
<string id="SubtitleFontHelper.event.DebugLog" value="%1" />
</stringTable>
</resources>
</localization>
Expand Down

0 comments on commit f02fed5

Please sign in to comment.