aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/dutil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-06-22 19:06:48 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-06-24 20:23:44 +1000
commit7fc25bc32547277c38bbedceb39c454843af8aac (patch)
treeddc28b69bc4d39a15fd788069a5d8a0f903a0ad4 /src/dutil/dutil.cpp
parent57536725e6061c7f6cd0f532c07beca7cd1228c9 (diff)
downloadwix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.gz
wix-7fc25bc32547277c38bbedceb39c454843af8aac.tar.bz2
wix-7fc25bc32547277c38bbedceb39c454843af8aac.zip
Replace ExitTrace with new DUTIL_CALLBACK_TRACEERROR callback.
This allows capturing internal dutil errors and eventually supports filtering to certain parts of dutil. Add Exit...Source macros to simplify calling both TraceError/TraceErrorDebug and Dutil_TraceErrorSource. Make existing Exit macros call the new Exit...Source macros so the logic is in one place.
Diffstat (limited to 'src/dutil/dutil.cpp')
-rw-r--r--src/dutil/dutil.cpp41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/dutil/dutil.cpp b/src/dutil/dutil.cpp
index 3945d8c1..a32de516 100644
--- a/src/dutil/dutil.cpp
+++ b/src/dutil/dutil.cpp
@@ -13,8 +13,26 @@ static DUTIL_ASSERTDISPLAYFUNCTION Dutil_pfnDisplayAssert = NULL;
13static BOOL Dutil_fNoAsserts = FALSE; 13static BOOL Dutil_fNoAsserts = FALSE;
14static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD; 14static REPORT_LEVEL Dutil_rlCurrentTrace = REPORT_STANDARD;
15static BOOL Dutil_fTraceFilenames = FALSE; 15static BOOL Dutil_fTraceFilenames = FALSE;
16static DUTIL_CALLBACK_TRACEERROR vpfnTraceErrorCallback = NULL;
16 17
17 18
19DAPI_(HRESULT) DutilInitialize(
20 __in_opt DUTIL_CALLBACK_TRACEERROR pfnTraceErrorCallback
21 )
22{
23 HRESULT hr = S_OK;
24
25 vpfnTraceErrorCallback = pfnTraceErrorCallback;
26
27 return hr;
28}
29
30
31DAPI_(void) DutilUninitialize()
32{
33 vpfnTraceErrorCallback = NULL;
34}
35
18/******************************************************************* 36/*******************************************************************
19Dutil_SetAssertModule 37Dutil_SetAssertModule
20 38
@@ -216,7 +234,7 @@ extern "C" REPORT_LEVEL DAPI Dutil_TraceGetLevel()
216Dutil_Trace 234Dutil_Trace
217 235
218*******************************************************************/ 236*******************************************************************/
219extern "C" void DAPI Dutil_Trace( 237extern "C" void DAPIV Dutil_Trace(
220 __in_z LPCSTR szFile, 238 __in_z LPCSTR szFile,
221 __in int iLine, 239 __in int iLine,
222 __in REPORT_LEVEL rl, 240 __in REPORT_LEVEL rl,
@@ -293,7 +311,7 @@ extern "C" void DAPI Dutil_Trace(
293Dutil_TraceError 311Dutil_TraceError
294 312
295*******************************************************************/ 313*******************************************************************/
296extern "C" void DAPI Dutil_TraceError( 314extern "C" void DAPIV Dutil_TraceError(
297 __in_z LPCSTR szFile, 315 __in_z LPCSTR szFile,
298 __in int iLine, 316 __in int iLine,
299 __in REPORT_LEVEL rl, 317 __in REPORT_LEVEL rl,
@@ -380,6 +398,25 @@ extern "C" void DAPI Dutil_TraceError(
380} 398}
381 399
382 400
401DAPIV_(void) Dutil_TraceErrorSource(
402 __in_z LPCSTR szFile,
403 __in int iLine,
404 __in REPORT_LEVEL rl,
405 __in UINT source,
406 __in HRESULT hr,
407 __in_z __format_string LPCSTR szFormat,
408 ...
409 )
410{
411 if (DUTIL_SOURCE_UNKNOWN != source && vpfnTraceErrorCallback)
412 {
413 va_list args;
414 va_start(args, szFormat);
415 vpfnTraceErrorCallback(szFile, iLine, rl, source, hr, szFormat, args);
416 va_end(args);
417 }
418}
419
383 420
384/******************************************************************* 421/*******************************************************************
385Dutil_RootFailure 422Dutil_RootFailure