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