-
Notifications
You must be signed in to change notification settings - Fork 430
Expand file tree
/
Copy pathDeploymentTraceLogging.h
More file actions
106 lines (94 loc) · 4.58 KB
/
DeploymentTraceLogging.h
File metadata and controls
106 lines (94 loc) · 4.58 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
#pragma once
#include <wil/resource.h>
#include <wil/result_macros.h>
#include <WindowsAppRuntimeInsights.h>
void __stdcall wilResultLoggingCallback(const wil::FailureInfo& failure) noexcept;
class WindowsAppRuntimeDeployment_TraceLogger final : public wil::TraceLoggingProvider
{
IMPLEMENT_TRACELOGGING_CLASS(
WindowsAppRuntimeDeployment_TraceLogger,
"Microsoft.WindowsAppRuntime.Deployment",
// {838d2cc1-0efb-564a-47bf-faba17949992}
(0x838d2cc1, 0x0efb, 0x564a, 0x47, 0xbf, 0xfa, 0xba, 0x17, 0x94, 0x99, 0x92));
public:
BEGIN_COMPLIANT_CRITICAL_DATA_ACTIVITY_CLASS(Initialize, PDT_ProductAndServicePerformance);
void StartActivity(bool forceDeployment, bool isElevated, bool isPackagedProcess, bool isFullTrustPackage, DWORD integrityLevel, bool isRepair, bool isGetStatus = false)
{
// Clear the process-wide callback set in Start
wil::SetResultLoggingCallback(nullptr);
// Set a process-wide callback function for WIL to call each time it logs a failure.
wil::SetResultLoggingCallback(wilResultLoggingCallback);
TraceLoggingClassWriteStart(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(forceDeployment, "forceDeployment"),
TraceLoggingValue(isElevated, "isElevated"),
TraceLoggingValue(isPackagedProcess, "isPackagedProcess"),
TraceLoggingValue(isFullTrustPackage, "isFullTrustPackage"),
TraceLoggingValue(integrityLevel, "integrityLevel"),
TraceLoggingValue(isRepair, "isRepairAPI"),
TraceLoggingValue(isGetStatus, "isGetStatusAPI"));
}
void StopWithResult(
HRESULT hresult,
UINT32 failureType,
PCSTR failureFile,
unsigned int failureLineNumber,
PCWSTR failureMessage,
PCSTR failureModule,
UINT32 preInitializeStatus,
UINT32 installStage,
PCWSTR currentResourceId,
HRESULT deploymentErrorExtendedHResult,
PCWSTR deploymentErrorText,
GUID deploymentErrorActivityId,
bool useExistingPackageIfHigherVersion)
{
// Set a process-wide callback function for WIL to call each time it logs a failure.
wil::SetResultLoggingCallback(nullptr);
SetStopResult(hresult);
if (FAILED(hresult))
{
TraceLoggingClassWriteStop(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(failureType, "WilFailureType"),
TraceLoggingValue(failureFile, "FailureFile"),
TraceLoggingValue(failureLineNumber, "FailureLineNumber"),
TraceLoggingValue(failureMessage, "FailureMessage"),
TraceLoggingValue(failureModule, "FailureModule"),
TraceLoggingValue(installStage, "FailedInstallStage"),
TraceLoggingValue(currentResourceId, "CurrentResourceId"),
TraceLoggingValue(deploymentErrorExtendedHResult, "DeploymentErrorExtendedHResult"),
TraceLoggingValue(deploymentErrorText, "DeploymentErrorText"),
TraceLoggingValue(deploymentErrorActivityId, "DeploymentErrorActivityId"),
TraceLoggingValue(useExistingPackageIfHigherVersion, "useExistingPackageIfHigherVersion"));
}
else
{
TraceLoggingClassWriteStop(Initialize,
_GENERIC_PARTB_FIELDS_ENABLED,
TraceLoggingValue(preInitializeStatus, "preInitializeStatus"));
}
}
END_ACTIVITY_CLASS();
};
#define WindowsAppRuntimeDeployment_TraceLoggingWString(_wstring_, _name_) \
TraceLoggingCountedWideString(\
_wstring_.c_str(),\
static_cast<ULONG>(_wstring_.size()), _name_)
// In the future, if the project includes multiple modules and threads, we could log that data as well from FailureInfo
// In the future and on need basis, we could log call stack as well
#define WindowsAppRuntimeDeployment_WriteEventWithActivity(_eventname_,...) TraceLoggingWriteActivity(\
WindowsAppRuntimeDeployment_TraceLogger::Provider(),\
_eventname_,\
WindowsAppRuntime::Deployment::Activity::Context::Get().GetActivity().Id(),\
nullptr,\
TraceLoggingValue(static_cast<uint32_t>(failure.type), "Type"),\
TraceLoggingValue(failure.hr, "HResult"),\
TraceLoggingValue(failure.pszFile, "File"),\
TraceLoggingValue(failure.uLineNumber, "Line"),\
TraceLoggingValue(failure.pszMessage, "Message"),\
TraceLoggingValue(failure.pszModule, "Module"),\
_GENERIC_PARTB_FIELDS_ENABLED,\
__VA_ARGS__)