forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.cpp
65 lines (57 loc) · 2.23 KB
/
trace.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "pch.h"
#include "trace.h"
#include "general_settings.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());
void Trace::RegisterProvider()
{
TraceLoggingRegister(g_hProvider);
}
void Trace::UnregisterProvider()
{
TraceLoggingUnregister(g_hProvider);
}
void Trace::EventLaunch(const std::wstring& versionNumber, bool isProcessElevated)
{
TraceLoggingWrite(
g_hProvider,
"Runner_Launch",
TraceLoggingWideString(versionNumber.c_str(), "Version"),
TraceLoggingBoolean(isProcessElevated, "Elevated"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}
void Trace::SettingsChanged(const GeneralSettings& settings)
{
std::wstring enabledModules;
for (const auto& [name, isEnabled] : settings.isModulesEnabledMap)
{
if (isEnabled)
{
if (!enabledModules.empty())
{
enabledModules += L", ";
}
enabledModules += name;
}
}
TraceLoggingWrite(
g_hProvider,
"GeneralSettingsChanged",
TraceLoggingBoolean(settings.isStartupEnabled, "RunAtStartup"),
TraceLoggingBoolean(settings.enableWarningsElevatedApps, "EnableWarningsElevatedApps"),
TraceLoggingWideString(settings.startupDisabledReason.c_str(), "StartupDisabledReason"),
TraceLoggingWideString(enabledModules.c_str(), "ModulesEnabled"),
TraceLoggingBoolean(settings.isRunElevated, "AlwaysRunElevated"),
TraceLoggingBoolean(settings.downloadUpdatesAutomatically, "DownloadUpdatesAutomatically"),
TraceLoggingBoolean(settings.enableExperimentation, "EnableExperimentation"),
TraceLoggingWideString(settings.theme.c_str(), "Theme"),
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
TraceLoggingBoolean(TRUE, "UTCReplace_AppSessionGuid"),
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
}