aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/inc/logutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/logutil.h')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/inc/logutil.h192
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
6extern "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
15typedef HRESULT (DAPI *PFN_LOGSTRINGWORKRAW)(
16 __in_z LPCSTR szString,
17 __in_opt LPVOID pvContext
18 );
19
20// enums
21
22// structs
23
24// functions
25BOOL DAPI IsLogInitialized();
26
27BOOL DAPI IsLogOpen();
28
29void DAPI LogInitialize(
30 __in HMODULE hModule
31 );
32
33HRESULT 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
43void DAPI LogDisable();
44
45void DAPI LogRedirect(
46 __in_opt PFN_LOGSTRINGWORKRAW vpfLogStringWorkRaw,
47 __in_opt LPVOID pvContext
48 );
49
50HRESULT DAPI LogRename(
51 __in_z LPCWSTR wzNewPath
52 );
53
54void DAPI LogClose(
55 __in BOOL fFooter
56 );
57
58void DAPI LogUninitialize(
59 __in BOOL fFooter
60 );
61
62BOOL DAPI LogIsOpen();
63
64HRESULT DAPI LogSetSpecialParams(
65 __in_z_opt LPCWSTR wzSpecialBeginLine,
66 __in_z_opt LPCWSTR wzSpecialAfterTimeStamp,
67 __in_z_opt LPCWSTR wzSpecialEndLine
68 );
69
70REPORT_LEVEL DAPI LogSetLevel(
71 __in REPORT_LEVEL rl,
72 __in BOOL fLogChange
73 );
74
75REPORT_LEVEL DAPI LogGetLevel();
76
77HRESULT DAPI LogGetPath(
78 __out_ecount_z(cchLogPath) LPWSTR pwzLogPath,
79 __in DWORD cchLogPath
80 );
81
82HANDLE DAPI LogGetHandle();
83
84HRESULT DAPIV LogString(
85 __in REPORT_LEVEL rl,
86 __in_z __format_string LPCSTR szFormat,
87 ...
88 );
89
90HRESULT DAPI LogStringArgs(
91 __in REPORT_LEVEL rl,
92 __in_z __format_string LPCSTR szFormat,
93 __in va_list args
94 );
95
96HRESULT DAPIV LogStringLine(
97 __in REPORT_LEVEL rl,
98 __in_z __format_string LPCSTR szFormat,
99 ...
100 );
101
102HRESULT DAPI LogStringLineArgs(
103 __in REPORT_LEVEL rl,
104 __in_z __format_string LPCSTR szFormat,
105 __in va_list args
106 );
107
108HRESULT 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
119inline 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
140inline 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
149HRESULT DAPIV LogErrorString(
150 __in HRESULT hrError,
151 __in_z __format_string LPCSTR szFormat,
152 ...
153 );
154
155HRESULT DAPI LogErrorStringArgs(
156 __in HRESULT hrError,
157 __in_z __format_string LPCSTR szFormat,
158 __in va_list args
159 );
160
161HRESULT 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
170inline 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
181HRESULT DAPI LogHeader();
182
183HRESULT DAPI LogFooter();
184
185HRESULT LogStringWorkRaw(
186 __in_z LPCSTR szLogData
187 );
188
189#ifdef __cplusplus
190}
191#endif
192