diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-09-02 16:06:53 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-09-03 15:29:26 -0500 |
commit | 85735f8b50a9dae190b08abe339aeda7a447a30b (patch) | |
tree | 29ea037c5f2faad2797da3affe68c2d8c83665c6 /src/libs/dutil/WixToolset.DUtil/inc | |
parent | 75bc4c3bcf2dcb85fdc642547e339f54775db43a (diff) | |
download | wix-85735f8b50a9dae190b08abe339aeda7a447a30b.tar.gz wix-85735f8b50a9dae190b08abe339aeda7a447a30b.tar.bz2 wix-85735f8b50a9dae190b08abe339aeda7a447a30b.zip |
Move logutil docs into header and standardize inline wrapper methods.
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/logutil.h | 202 |
1 files changed, 181 insertions, 21 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/logutil.h b/src/libs/dutil/WixToolset.DUtil/inc/logutil.h index 8f38e0ce..0ad8510a 100644 --- a/src/libs/dutil/WixToolset.DUtil/inc/logutil.h +++ b/src/libs/dutil/WixToolset.DUtil/inc/logutil.h | |||
@@ -24,14 +24,29 @@ typedef HRESULT (DAPI *PFN_LOGSTRINGWORKRAW)( | |||
24 | // structs | 24 | // structs |
25 | 25 | ||
26 | // functions | 26 | // functions |
27 | /******************************************************************** | ||
28 | IsLogInitialized - Checks if log is currently initialized. | ||
29 | ********************************************************************/ | ||
27 | BOOL DAPI IsLogInitialized(); | 30 | BOOL DAPI IsLogInitialized(); |
28 | 31 | ||
32 | /******************************************************************** | ||
33 | IsLogOpen - Checks if log is currently initialized and open. | ||
34 | ********************************************************************/ | ||
29 | BOOL DAPI IsLogOpen(); | 35 | BOOL DAPI IsLogOpen(); |
30 | 36 | ||
37 | /******************************************************************** | ||
38 | LogInitialize - initializes the logutil API | ||
39 | |||
40 | ********************************************************************/ | ||
31 | void DAPI LogInitialize( | 41 | void DAPI LogInitialize( |
32 | __in_opt HMODULE hModule | 42 | __in_opt HMODULE hModule |
33 | ); | 43 | ); |
34 | 44 | ||
45 | /******************************************************************** | ||
46 | LogOpen - creates an application log file | ||
47 | |||
48 | NOTE: if wzExt is null then wzLog is path to desired log else wzLog and wzExt are used to generate log name | ||
49 | ********************************************************************/ | ||
35 | HRESULT DAPI LogOpen( | 50 | HRESULT DAPI LogOpen( |
36 | __in_z_opt LPCWSTR wzDirectory, | 51 | __in_z_opt LPCWSTR wzDirectory, |
37 | __in_z LPCWSTR wzLog, | 52 | __in_z LPCWSTR wzLog, |
@@ -42,13 +57,26 @@ HRESULT DAPI LogOpen( | |||
42 | __out_z_opt LPWSTR* psczLogPath | 57 | __out_z_opt LPWSTR* psczLogPath |
43 | ); | 58 | ); |
44 | 59 | ||
60 | /******************************************************************** | ||
61 | LogDisable - closes any open files and disables in memory logging. | ||
62 | |||
63 | ********************************************************************/ | ||
45 | void DAPI LogDisable(); | 64 | void DAPI LogDisable(); |
46 | 65 | ||
66 | /******************************************************************** | ||
67 | LogRedirect - Redirects all logging strings to the specified | ||
68 | function - or set NULL to disable the hook | ||
69 | ********************************************************************/ | ||
47 | void DAPI LogRedirect( | 70 | void DAPI LogRedirect( |
48 | __in_opt PFN_LOGSTRINGWORKRAW vpfLogStringWorkRaw, | 71 | __in_opt PFN_LOGSTRINGWORKRAW vpfLogStringWorkRaw, |
49 | __in_opt LPVOID pvContext | 72 | __in_opt LPVOID pvContext |
50 | ); | 73 | ); |
51 | 74 | ||
75 | /******************************************************************** | ||
76 | LogRename - Renames a logfile, moving its contents to a new path, | ||
77 | and re-opening the file for appending at the new | ||
78 | location | ||
79 | ********************************************************************/ | ||
52 | HRESULT DAPI LogRename( | 80 | HRESULT DAPI LogRename( |
53 | __in_z LPCWSTR wzNewPath | 81 | __in_z LPCWSTR wzNewPath |
54 | ); | 82 | ); |
@@ -61,52 +89,119 @@ void DAPI LogUninitialize( | |||
61 | __in BOOL fFooter | 89 | __in BOOL fFooter |
62 | ); | 90 | ); |
63 | 91 | ||
92 | /******************************************************************** | ||
93 | LogIsOpen - returns whether log file is open or note | ||
94 | |||
95 | ********************************************************************/ | ||
64 | BOOL DAPI LogIsOpen(); | 96 | BOOL DAPI LogIsOpen(); |
65 | 97 | ||
98 | /******************************************************************** | ||
99 | LogSetSpecialParams - sets a special beginline string, endline | ||
100 | string, post-timestamp string, etc. | ||
101 | ********************************************************************/ | ||
66 | HRESULT DAPI LogSetSpecialParams( | 102 | HRESULT DAPI LogSetSpecialParams( |
67 | __in_z_opt LPCWSTR wzSpecialBeginLine, | 103 | __in_z_opt LPCWSTR wzSpecialBeginLine, |
68 | __in_z_opt LPCWSTR wzSpecialAfterTimeStamp, | 104 | __in_z_opt LPCWSTR wzSpecialAfterTimeStamp, |
69 | __in_z_opt LPCWSTR wzSpecialEndLine | 105 | __in_z_opt LPCWSTR wzSpecialEndLine |
70 | ); | 106 | ); |
71 | 107 | ||
108 | /******************************************************************** | ||
109 | LogSetLevel - sets the logging level | ||
110 | |||
111 | NOTE: returns previous logging level | ||
112 | ********************************************************************/ | ||
72 | REPORT_LEVEL DAPI LogSetLevel( | 113 | REPORT_LEVEL DAPI LogSetLevel( |
73 | __in REPORT_LEVEL rl, | 114 | __in REPORT_LEVEL rl, |
74 | __in BOOL fLogChange | 115 | __in BOOL fLogChange |
75 | ); | 116 | ); |
76 | 117 | ||
118 | /******************************************************************** | ||
119 | LogGetLevel - gets the current logging level | ||
120 | |||
121 | ********************************************************************/ | ||
77 | REPORT_LEVEL DAPI LogGetLevel(); | 122 | REPORT_LEVEL DAPI LogGetLevel(); |
78 | 123 | ||
124 | /******************************************************************** | ||
125 | LogGetPath - gets the current log path | ||
126 | |||
127 | ********************************************************************/ | ||
79 | HRESULT DAPI LogGetPath( | 128 | HRESULT DAPI LogGetPath( |
80 | __out_ecount_z(cchLogPath) LPWSTR pwzLogPath, | 129 | __out_ecount_z(cchLogPath) LPWSTR pwzLogPath, |
81 | __in DWORD cchLogPath | 130 | __in DWORD cchLogPath |
82 | ); | 131 | ); |
83 | 132 | ||
133 | /******************************************************************** | ||
134 | LogGetHandle - gets the current log file handle | ||
135 | |||
136 | ********************************************************************/ | ||
84 | HANDLE DAPI LogGetHandle(); | 137 | HANDLE DAPI LogGetHandle(); |
85 | 138 | ||
86 | HRESULT DAPIV LogString( | 139 | /******************************************************************** |
87 | __in REPORT_LEVEL rl, | 140 | LogStringArgs - implementation of LogString |
88 | __in_z __format_string LPCSTR szFormat, | ||
89 | ... | ||
90 | ); | ||
91 | 141 | ||
142 | ********************************************************************/ | ||
92 | HRESULT DAPI LogStringArgs( | 143 | HRESULT DAPI LogStringArgs( |
93 | __in REPORT_LEVEL rl, | 144 | __in REPORT_LEVEL rl, |
94 | __in_z __format_string LPCSTR szFormat, | 145 | __in_z __format_string LPCSTR szFormat, |
95 | __in va_list args | 146 | __in va_list args |
96 | ); | 147 | ); |
97 | 148 | ||
98 | HRESULT DAPIV LogStringLine( | 149 | /******************************************************************** |
150 | LogString - write a string to the log | ||
151 | |||
152 | NOTE: use printf formatting ("%ls", "%d", etc.) | ||
153 | ********************************************************************/ | ||
154 | inline HRESULT LogString( | ||
99 | __in REPORT_LEVEL rl, | 155 | __in REPORT_LEVEL rl, |
100 | __in_z __format_string LPCSTR szFormat, | 156 | __in_z __format_string LPCSTR szFormat, |
101 | ... | 157 | ... |
102 | ); | 158 | ) |
159 | { | ||
160 | HRESULT hr = S_OK; | ||
161 | va_list args; | ||
162 | |||
163 | va_start(args, szFormat); | ||
164 | hr = LogStringArgs(rl, szFormat, args); | ||
165 | va_end(args); | ||
103 | 166 | ||
167 | return hr; | ||
168 | } | ||
169 | |||
170 | /******************************************************************** | ||
171 | LogStringLineArgs - implementation of LogStringLine | ||
172 | |||
173 | ********************************************************************/ | ||
104 | HRESULT DAPI LogStringLineArgs( | 174 | HRESULT DAPI LogStringLineArgs( |
105 | __in REPORT_LEVEL rl, | 175 | __in REPORT_LEVEL rl, |
106 | __in_z __format_string LPCSTR szFormat, | 176 | __in_z __format_string LPCSTR szFormat, |
107 | __in va_list args | 177 | __in va_list args |
108 | ); | 178 | ); |
109 | 179 | ||
180 | /******************************************************************** | ||
181 | LogStringLine - write a string plus LOGUTIL_NEWLINE to the log | ||
182 | |||
183 | NOTE: use printf formatting ("%ls", "%d", etc.) | ||
184 | ********************************************************************/ | ||
185 | inline HRESULT LogStringLine( | ||
186 | __in REPORT_LEVEL rl, | ||
187 | __in_z __format_string LPCSTR szFormat, | ||
188 | ... | ||
189 | ) | ||
190 | { | ||
191 | HRESULT hr = S_OK; | ||
192 | va_list args; | ||
193 | |||
194 | va_start(args, szFormat); | ||
195 | hr = LogStringLineArgs(rl, szFormat, args); | ||
196 | va_end(args); | ||
197 | |||
198 | return hr; | ||
199 | } | ||
200 | |||
201 | /******************************************************************** | ||
202 | LogIdModuleArgs - implementation of LogIdModule | ||
203 | |||
204 | ********************************************************************/ | ||
110 | HRESULT DAPI LogIdModuleArgs( | 205 | HRESULT DAPI LogIdModuleArgs( |
111 | __in REPORT_LEVEL rl, | 206 | __in REPORT_LEVEL rl, |
112 | __in DWORD dwLogId, | 207 | __in DWORD dwLogId, |
@@ -114,31 +209,32 @@ HRESULT DAPI LogIdModuleArgs( | |||
114 | __in va_list args | 209 | __in va_list args |
115 | ); | 210 | ); |
116 | 211 | ||
117 | /* | 212 | /******************************************************************** |
118 | * Wraps LogIdModuleArgs, so inline to save the function call | 213 | LogIdModule - write a string embedded in a MESSAGETABLE in the specified module to the log |
119 | */ | ||
120 | 214 | ||
121 | inline HRESULT LogId( | 215 | NOTE: uses format string from MESSAGETABLE resource |
216 | ********************************************************************/ | ||
217 | inline HRESULT LogIdModule( | ||
122 | __in REPORT_LEVEL rl, | 218 | __in REPORT_LEVEL rl, |
123 | __in DWORD dwLogId, | 219 | __in DWORD dwLogId, |
220 | __in_opt HMODULE hModule, | ||
124 | ... | 221 | ... |
125 | ) | 222 | ) |
126 | { | 223 | { |
127 | HRESULT hr = S_OK; | 224 | HRESULT hr = S_OK; |
128 | va_list args; | 225 | va_list args; |
129 | 226 | ||
130 | va_start(args, dwLogId); | 227 | va_start(args, hModule); |
131 | hr = LogIdModuleArgs(rl, dwLogId, NULL, args); | 228 | hr = LogIdModuleArgs(rl, dwLogId, hModule, args); |
132 | va_end(args); | 229 | va_end(args); |
133 | 230 | ||
134 | return hr; | 231 | return hr; |
135 | } | 232 | } |
136 | 233 | ||
234 | /******************************************************************** | ||
235 | LogIdArgs - inline wrapper for LogIdModuleArgs, passing NULL for hModule | ||
137 | 236 | ||
138 | /* | 237 | ********************************************************************/ |
139 | * Wraps LogIdModuleArgs, so inline to save the function call | ||
140 | */ | ||
141 | |||
142 | inline HRESULT LogIdArgs( | 238 | inline HRESULT LogIdArgs( |
143 | __in REPORT_LEVEL rl, | 239 | __in REPORT_LEVEL rl, |
144 | __in DWORD dwLogId, | 240 | __in DWORD dwLogId, |
@@ -148,18 +244,64 @@ inline HRESULT LogIdArgs( | |||
148 | return LogIdModuleArgs(rl, dwLogId, NULL, args); | 244 | return LogIdModuleArgs(rl, dwLogId, NULL, args); |
149 | } | 245 | } |
150 | 246 | ||
151 | HRESULT DAPIV LogErrorString( | 247 | /******************************************************************** |
152 | __in HRESULT hrError, | 248 | LogId - write a string embedded in a MESSAGETABLE in the default module to the log |
153 | __in_z __format_string LPCSTR szFormat, | 249 | |
250 | NOTE: uses format string from MESSAGETABLE resource | ||
251 | ********************************************************************/ | ||
252 | inline HRESULT LogId( | ||
253 | __in REPORT_LEVEL rl, | ||
254 | __in DWORD dwLogId, | ||
154 | ... | 255 | ... |
155 | ); | 256 | ) |
257 | { | ||
258 | HRESULT hr = S_OK; | ||
259 | va_list args; | ||
260 | |||
261 | va_start(args, dwLogId); | ||
262 | hr = LogIdArgs(rl, dwLogId, args); | ||
263 | va_end(args); | ||
264 | |||
265 | return hr; | ||
266 | } | ||
156 | 267 | ||
268 | /******************************************************************** | ||
269 | LogErrorStringArgs - implementation of LogErrorString | ||
270 | |||
271 | ********************************************************************/ | ||
157 | HRESULT DAPI LogErrorStringArgs( | 272 | HRESULT DAPI LogErrorStringArgs( |
158 | __in HRESULT hrError, | 273 | __in HRESULT hrError, |
159 | __in_z __format_string LPCSTR szFormat, | 274 | __in_z __format_string LPCSTR szFormat, |
160 | __in va_list args | 275 | __in va_list args |
161 | ); | 276 | ); |
162 | 277 | ||
278 | /******************************************************************** | ||
279 | LogErrorString - write an error to the log | ||
280 | |||
281 | NOTE: use printf formatting ("%ls", "%d", etc.) | ||
282 | ********************************************************************/ | ||
283 | inline HRESULT LogErrorString( | ||
284 | __in HRESULT hrError, | ||
285 | __in_z __format_string LPCSTR szFormat, | ||
286 | ... | ||
287 | ) | ||
288 | { | ||
289 | HRESULT hr = S_OK; | ||
290 | |||
291 | va_list args; | ||
292 | va_start(args, szFormat); | ||
293 | hr = LogErrorStringArgs(hrError, szFormat, args); | ||
294 | va_end(args); | ||
295 | |||
296 | return hr; | ||
297 | } | ||
298 | |||
299 | /******************************************************************** | ||
300 | LogErrorIdModule - write an error string embedded in the specified module in a MESSAGETABLE to the log | ||
301 | |||
302 | NOTE: uses format string from MESSAGETABLE resource | ||
303 | can log no more than three strings in the error message | ||
304 | ********************************************************************/ | ||
163 | HRESULT DAPI LogErrorIdModule( | 305 | HRESULT DAPI LogErrorIdModule( |
164 | __in HRESULT hrError, | 306 | __in HRESULT hrError, |
165 | __in DWORD dwLogId, | 307 | __in DWORD dwLogId, |
@@ -169,6 +311,12 @@ HRESULT DAPI LogErrorIdModule( | |||
169 | __in_z_opt LPCWSTR wzString3 | 311 | __in_z_opt LPCWSTR wzString3 |
170 | ); | 312 | ); |
171 | 313 | ||
314 | /******************************************************************** | ||
315 | LogErrorId - write an error string embedded in the default module in a MESSAGETABLE to the log | ||
316 | |||
317 | NOTE: uses format string from MESSAGETABLE resource | ||
318 | can log no more than three strings in the error message | ||
319 | ********************************************************************/ | ||
172 | inline HRESULT LogErrorId( | 320 | inline HRESULT LogErrorId( |
173 | __in HRESULT hrError, | 321 | __in HRESULT hrError, |
174 | __in DWORD dwLogId, | 322 | __in DWORD dwLogId, |
@@ -180,10 +328,22 @@ inline HRESULT LogErrorId( | |||
180 | return LogErrorIdModule(hrError, dwLogId, NULL, wzString1, wzString2, wzString3); | 328 | return LogErrorIdModule(hrError, dwLogId, NULL, wzString1, wzString2, wzString3); |
181 | } | 329 | } |
182 | 330 | ||
331 | /******************************************************************** | ||
332 | LogHeader - write a standard header to the log | ||
333 | |||
334 | ********************************************************************/ | ||
183 | HRESULT DAPI LogHeader(); | 335 | HRESULT DAPI LogHeader(); |
184 | 336 | ||
337 | /******************************************************************** | ||
338 | LogFooter - write a standard footer to the log | ||
339 | |||
340 | ********************************************************************/ | ||
185 | HRESULT DAPI LogFooter(); | 341 | HRESULT DAPI LogFooter(); |
186 | 342 | ||
343 | /******************************************************************** | ||
344 | LogStringWorkRaw - Write a raw, unformatted string to the log | ||
345 | |||
346 | ********************************************************************/ | ||
187 | HRESULT LogStringWorkRaw( | 347 | HRESULT LogStringWorkRaw( |
188 | __in_z LPCSTR szLogData | 348 | __in_z LPCSTR szLogData |
189 | ); | 349 | ); |