PowerToys/src/settings/trace.cpp
2020-01-27 20:01:36 +03:00

46 lines
1.4 KiB
C++

#include "pch.h"
#include "trace.h"
TRACELOGGING_DEFINE_PROVIDER(
g_hProvider,
"Microsoft.PowerToys",
// {38e8889b-9731-53f5-e901-e8a7c1753074}
(0x38e8889b, 0x9731, 0x53f5, 0xe9, 0x01, 0xe8, 0xa7, 0xc1, 0x75, 0x30, 0x74),
TraceLoggingOptionProjectTelemetry());
const char* settingsInitErrorCauseAsString(Trace::SettingsInitErrorCause error_case)
{
switch (error_case)
{
case Trace::SettingsInitErrorCause::WebViewInitAsyncError:
return "WebViewInitAsyncError";
case Trace::SettingsInitErrorCause::WebViewInitWinRTException:
return "WebViewInitWinRTException";
case Trace::SettingsInitErrorCause::FailedToDropPrivileges:
return "FailedToDropPrivileges";
default:
return "UnknownError";
};
}
void Trace::SettingsInitError(const Trace::SettingsInitErrorCause error_cause)
{
TraceLoggingWrite(
g_hProvider,
"PowerToysSettings_SettingsInitError",
TraceLoggingString(settingsInitErrorCauseAsString(error_cause), "Cause"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
void Trace::RegisterProvider() noexcept
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider() noexcept
{
TraceLoggingUnregister(g_hProvider);
}