diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/logutil.h')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/logutil.h | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/logutil.h b/src/libs/dutil/WixToolset.DUtil/inc/logutil.h new file mode 100644 index 00000000..426506ee --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/inc/logutil.h | |||
@@ -0,0 +1,192 @@ | |||
1 | #pragma once | ||
2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
3 | |||
4 | |||
5 | #ifdef __cplusplus | ||
6 | extern "C" { | ||
7 | #endif | ||
8 | |||
9 | #define LogExitOnFailureSource(d, x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
10 | #define LogExitOnRootFailureSource(d, x, i, f, ...) if (FAILED(x)) { LogErrorId(x, i, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
11 | |||
12 | #define LogExitOnFailure(x, i, f, ...) LogExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, i, f, __VA_ARGS__) | ||
13 | #define LogExitOnRootFailure(x, i, f, ...) LogExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, i, f, __VA_ARGS__) | ||
14 | |||
15 | typedef HRESULT (DAPI *PFN_LOGSTRINGWORKRAW)( | ||
16 | __in_z LPCSTR szString, | ||
17 | __in_opt LPVOID pvContext | ||
18 | ); | ||
19 | |||
20 | // enums | ||
21 | |||
22 | // structs | ||
23 | |||
24 | // functions | ||
25 | BOOL DAPI IsLogInitialized(); | ||
26 | |||
27 | BOOL DAPI IsLogOpen(); | ||
28 | |||
29 | void DAPI LogInitialize( | ||
30 | __in HMODULE hModule | ||
31 | ); | ||
32 | |||
33 | HRESULT DAPI LogOpen( | ||
34 | __in_z_opt LPCWSTR wzDirectory, | ||
35 | __in_z LPCWSTR wzLog, | ||
36 | __in_z_opt LPCWSTR wzPostfix, | ||
37 | __in_z_opt LPCWSTR wzExt, | ||
38 | __in BOOL fAppend, | ||
39 | __in BOOL fHeader, | ||
40 | __out_z_opt LPWSTR* psczLogPath | ||
41 | ); | ||
42 | |||
43 | void DAPI LogDisable(); | ||
44 | |||
45 | void DAPI LogRedirect( | ||
46 | __in_opt PFN_LOGSTRINGWORKRAW vpfLogStringWorkRaw, | ||
47 | __in_opt LPVOID pvContext | ||
48 | ); | ||
49 | |||
50 | HRESULT DAPI LogRename( | ||
51 | __in_z LPCWSTR wzNewPath | ||
52 | ); | ||
53 | |||
54 | void DAPI LogClose( | ||
55 | __in BOOL fFooter | ||
56 | ); | ||
57 | |||
58 | void DAPI LogUninitialize( | ||
59 | __in BOOL fFooter | ||
60 | ); | ||
61 | |||
62 | BOOL DAPI LogIsOpen(); | ||
63 | |||
64 | HRESULT DAPI LogSetSpecialParams( | ||
65 | __in_z_opt LPCWSTR wzSpecialBeginLine, | ||
66 | __in_z_opt LPCWSTR wzSpecialAfterTimeStamp, | ||
67 | __in_z_opt LPCWSTR wzSpecialEndLine | ||
68 | ); | ||
69 | |||
70 | REPORT_LEVEL DAPI LogSetLevel( | ||
71 | __in REPORT_LEVEL rl, | ||
72 | __in BOOL fLogChange | ||
73 | ); | ||
74 | |||
75 | REPORT_LEVEL DAPI LogGetLevel(); | ||
76 | |||
77 | HRESULT DAPI LogGetPath( | ||
78 | __out_ecount_z(cchLogPath) LPWSTR pwzLogPath, | ||
79 | __in DWORD cchLogPath | ||
80 | ); | ||
81 | |||
82 | HANDLE DAPI LogGetHandle(); | ||
83 | |||
84 | HRESULT DAPIV LogString( | ||
85 | __in REPORT_LEVEL rl, | ||
86 | __in_z __format_string LPCSTR szFormat, | ||
87 | ... | ||
88 | ); | ||
89 | |||
90 | HRESULT DAPI LogStringArgs( | ||
91 | __in REPORT_LEVEL rl, | ||
92 | __in_z __format_string LPCSTR szFormat, | ||
93 | __in va_list args | ||
94 | ); | ||
95 | |||
96 | HRESULT DAPIV LogStringLine( | ||
97 | __in REPORT_LEVEL rl, | ||
98 | __in_z __format_string LPCSTR szFormat, | ||
99 | ... | ||
100 | ); | ||
101 | |||
102 | HRESULT DAPI LogStringLineArgs( | ||
103 | __in REPORT_LEVEL rl, | ||
104 | __in_z __format_string LPCSTR szFormat, | ||
105 | __in va_list args | ||
106 | ); | ||
107 | |||
108 | HRESULT DAPI LogIdModuleArgs( | ||
109 | __in REPORT_LEVEL rl, | ||
110 | __in DWORD dwLogId, | ||
111 | __in_opt HMODULE hModule, | ||
112 | __in va_list args | ||
113 | ); | ||
114 | |||
115 | /* | ||
116 | * Wraps LogIdModuleArgs, so inline to save the function call | ||
117 | */ | ||
118 | |||
119 | inline HRESULT LogId( | ||
120 | __in REPORT_LEVEL rl, | ||
121 | __in DWORD dwLogId, | ||
122 | ... | ||
123 | ) | ||
124 | { | ||
125 | HRESULT hr = S_OK; | ||
126 | va_list args; | ||
127 | |||
128 | va_start(args, dwLogId); | ||
129 | hr = LogIdModuleArgs(rl, dwLogId, NULL, args); | ||
130 | va_end(args); | ||
131 | |||
132 | return hr; | ||
133 | } | ||
134 | |||
135 | |||
136 | /* | ||
137 | * Wraps LogIdModuleArgs, so inline to save the function call | ||
138 | */ | ||
139 | |||
140 | inline HRESULT LogIdArgs( | ||
141 | __in REPORT_LEVEL rl, | ||
142 | __in DWORD dwLogId, | ||
143 | __in va_list args | ||
144 | ) | ||
145 | { | ||
146 | return LogIdModuleArgs(rl, dwLogId, NULL, args); | ||
147 | } | ||
148 | |||
149 | HRESULT DAPIV LogErrorString( | ||
150 | __in HRESULT hrError, | ||
151 | __in_z __format_string LPCSTR szFormat, | ||
152 | ... | ||
153 | ); | ||
154 | |||
155 | HRESULT DAPI LogErrorStringArgs( | ||
156 | __in HRESULT hrError, | ||
157 | __in_z __format_string LPCSTR szFormat, | ||
158 | __in va_list args | ||
159 | ); | ||
160 | |||
161 | HRESULT DAPI LogErrorIdModule( | ||
162 | __in HRESULT hrError, | ||
163 | __in DWORD dwLogId, | ||
164 | __in_opt HMODULE hModule, | ||
165 | __in_z_opt LPCWSTR wzString1, | ||
166 | __in_z_opt LPCWSTR wzString2, | ||
167 | __in_z_opt LPCWSTR wzString3 | ||
168 | ); | ||
169 | |||
170 | inline HRESULT LogErrorId( | ||
171 | __in HRESULT hrError, | ||
172 | __in DWORD dwLogId, | ||
173 | __in_z_opt LPCWSTR wzString1 = NULL, | ||
174 | __in_z_opt LPCWSTR wzString2 = NULL, | ||
175 | __in_z_opt LPCWSTR wzString3 = NULL | ||
176 | ) | ||
177 | { | ||
178 | return LogErrorIdModule(hrError, dwLogId, NULL, wzString1, wzString2, wzString3); | ||
179 | } | ||
180 | |||
181 | HRESULT DAPI LogHeader(); | ||
182 | |||
183 | HRESULT DAPI LogFooter(); | ||
184 | |||
185 | HRESULT LogStringWorkRaw( | ||
186 | __in_z LPCSTR szLogData | ||
187 | ); | ||
188 | |||
189 | #ifdef __cplusplus | ||
190 | } | ||
191 | #endif | ||
192 | |||