forked from microsoft/microsoft-ui-xaml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScrollViewTrace.h
154 lines (134 loc) · 5.48 KB
/
ScrollViewTrace.h
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "common.h"
#include "TraceLogging.h"
#include "Utils.h"
#include "MUXControlsTestHooks.h"
inline bool IsScrollViewTracingEnabled()
{
return g_IsLoggingProviderEnabled &&
g_LoggingProviderLevel >= WINEVENT_LEVEL_INFO &&
(g_LoggingProviderMatchAnyKeyword & KEYWORD_SCROLLVIEW || g_LoggingProviderMatchAnyKeyword == 0);
}
inline bool IsScrollViewVerboseTracingEnabled()
{
return g_IsLoggingProviderEnabled &&
g_LoggingProviderLevel >= WINEVENT_LEVEL_VERBOSE &&
(g_LoggingProviderMatchAnyKeyword & KEYWORD_SCROLLVIEW || g_LoggingProviderMatchAnyKeyword == 0);
}
inline bool IsScrollViewPerfTracingEnabled()
{
return g_IsPerfProviderEnabled &&
g_PerfProviderLevel >= WINEVENT_LEVEL_INFO &&
(g_PerfProviderMatchAnyKeyword & KEYWORD_SCROLLVIEW || g_PerfProviderMatchAnyKeyword == 0);
}
#define SCROLLVIEW_TRACE_INFO_ENABLED(includeTraceLogging, sender, message, ...) \
ScrollViewTrace::TraceInfo(includeTraceLogging, sender, message, __VA_ARGS__); \
#define SCROLLVIEW_TRACE_INFO(sender, message, ...) \
if (IsScrollViewTracingEnabled()) \
{ \
SCROLLVIEW_TRACE_INFO_ENABLED(true /*includeTraceLogging*/, sender, message, __VA_ARGS__); \
} \
else if (ScrollViewTrace::s_IsDebugOutputEnabled || ScrollViewTrace::s_IsVerboseDebugOutputEnabled) \
{ \
SCROLLVIEW_TRACE_INFO_ENABLED(false /*includeTraceLogging*/, sender, message, __VA_ARGS__); \
} \
#define SCROLLVIEW_TRACE_VERBOSE_ENABLED(includeTraceLogging, sender, message, ...) \
ScrollViewTrace::TraceVerbose(includeTraceLogging, sender, message, __VA_ARGS__); \
#define SCROLLVIEW_TRACE_VERBOSE(sender, message, ...) \
if (IsScrollViewVerboseTracingEnabled()) \
{ \
SCROLLVIEW_TRACE_VERBOSE_ENABLED(true /*includeTraceLogging*/, sender, message, __VA_ARGS__); \
} \
else if (ScrollViewTrace::s_IsVerboseDebugOutputEnabled) \
{ \
SCROLLVIEW_TRACE_VERBOSE_ENABLED(false /*includeTraceLogging*/, sender, message, __VA_ARGS__); \
} \
#define SCROLLVIEW_TRACE_PERF(info) \
if (IsScrollViewPerfTracingEnabled()) \
{ \
ScrollViewTrace::TracePerfInfo(info); \
} \
class ScrollViewTrace
{
public:
static bool s_IsDebugOutputEnabled;
static bool s_IsVerboseDebugOutputEnabled;
static void TraceInfo(bool includeTraceLogging, const winrt::IInspectable& sender, PCWSTR message, ...) noexcept
{
va_list args;
va_start(args, message);
WCHAR buffer[256]{};
if (SUCCEEDED(StringCchVPrintfW(buffer, ARRAYSIZE(buffer), message, args)))
{
if (includeTraceLogging)
{
// TraceViewers
// http://toolbox/pef
// http://fastetw/index.aspx
TraceLoggingWrite(
g_hLoggingProvider,
"ScrollViewInfo" /* eventName */,
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingKeyword(KEYWORD_SCROLLVIEW),
TraceLoggingWideString(buffer, "Message"));
}
if (s_IsDebugOutputEnabled)
{
OutputDebugStringW(buffer);
}
com_ptr<MUXControlsTestHooks> globalTestHooks = MUXControlsTestHooks::GetGlobalTestHooks();
if (globalTestHooks &&
(globalTestHooks->GetLoggingLevelForType(L"ScrollView") >= WINEVENT_LEVEL_INFO || globalTestHooks->GetLoggingLevelForInstance(sender) >= WINEVENT_LEVEL_INFO))
{
globalTestHooks->LogMessage(sender, buffer, false /*isVerboseLevel*/);
}
}
va_end(args);
}
static void TraceVerbose(bool includeTraceLogging, const winrt::IInspectable& sender, PCWSTR message, ...) noexcept
{
va_list args;
va_start(args, message);
WCHAR buffer[256]{};
if (SUCCEEDED(StringCchVPrintfW(buffer, ARRAYSIZE(buffer), message, args)))
{
if (includeTraceLogging)
{
// TraceViewers
// http://toolbox/pef
// http://fastetw/index.aspx
TraceLoggingWrite(
g_hLoggingProvider,
"ScrollViewVerbose" /* eventName */,
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
TraceLoggingKeyword(KEYWORD_SCROLLVIEW),
TraceLoggingWideString(buffer, "Message"));
}
if (s_IsDebugOutputEnabled || s_IsVerboseDebugOutputEnabled)
{
OutputDebugStringW(buffer);
}
com_ptr<MUXControlsTestHooks> globalTestHooks = MUXControlsTestHooks::GetGlobalTestHooks();
if (globalTestHooks &&
(globalTestHooks->GetLoggingLevelForType(L"ScrollView") >= WINEVENT_LEVEL_VERBOSE || globalTestHooks->GetLoggingLevelForInstance(sender) >= WINEVENT_LEVEL_VERBOSE))
{
globalTestHooks->LogMessage(sender, buffer, true /*isVerboseLevel*/);
}
}
va_end(args);
}
static void TracePerfInfo(PCWSTR info) noexcept
{
// TraceViewers
// http://toolbox/pef
// http://fastetw/index.aspx
TraceLoggingWrite(
g_hPerfProvider,
"ScrollViewPerf" /* eventName */,
TraceLoggingLevel(WINEVENT_LEVEL_INFO),
TraceLoggingKeyword(KEYWORD_SCROLLVIEW),
TraceLoggingWideString(info, "Info"));
}
};