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