1 | /** @file
|
---|
2 | * IPRT - Logging.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_log_h
|
---|
37 | #define IPRT_INCLUDED_log_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/cdefs.h>
|
---|
43 | #include <iprt/types.h>
|
---|
44 | #include <iprt/stdarg.h>
|
---|
45 |
|
---|
46 | RT_C_DECLS_BEGIN
|
---|
47 |
|
---|
48 | /** @defgroup grp_rt_log RTLog - Logging
|
---|
49 | * @ingroup grp_rt
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * IPRT Logging Groups.
|
---|
55 | * (Remember to update RT_LOGGROUP_NAMES!)
|
---|
56 | *
|
---|
57 | * @remark It should be pretty obvious, but just to have
|
---|
58 | * mentioned it, the values are sorted alphabetically (using the
|
---|
59 | * english alphabet) except for _DEFAULT which is always first.
|
---|
60 | *
|
---|
61 | * If anyone might be wondering what the alphabet looks like:
|
---|
62 | * a b c d e f g h i j k l m n o p q r s t u v w x y z
|
---|
63 | */
|
---|
64 | typedef enum RTLOGGROUP
|
---|
65 | {
|
---|
66 | /** Default logging group. */
|
---|
67 | RTLOGGROUP_DEFAULT,
|
---|
68 | RTLOGGROUP_CRYPTO,
|
---|
69 | RTLOGGROUP_DBG,
|
---|
70 | RTLOGGROUP_DBG_DWARF,
|
---|
71 | RTLOGGROUP_DIR,
|
---|
72 | RTLOGGROUP_FDT,
|
---|
73 | RTLOGGROUP_FILE,
|
---|
74 | RTLOGGROUP_FS,
|
---|
75 | RTLOGGROUP_FTP,
|
---|
76 | RTLOGGROUP_HTTP,
|
---|
77 | RTLOGGROUP_IOQUEUE,
|
---|
78 | RTLOGGROUP_LDR,
|
---|
79 | RTLOGGROUP_LOCALIPC,
|
---|
80 | RTLOGGROUP_PATH,
|
---|
81 | RTLOGGROUP_PROCESS,
|
---|
82 | RTLOGGROUP_REST,
|
---|
83 | RTLOGGROUP_SYMLINK,
|
---|
84 | RTLOGGROUP_THREAD,
|
---|
85 | RTLOGGROUP_TIME,
|
---|
86 | RTLOGGROUP_TIMER,
|
---|
87 | RTLOGGROUP_VFS,
|
---|
88 | RTLOGGROUP_ZIP = 31,
|
---|
89 | RTLOGGROUP_FIRST_USER = 32
|
---|
90 | } RTLOGGROUP;
|
---|
91 |
|
---|
92 | /** @def RT_LOGGROUP_NAMES
|
---|
93 | * IPRT Logging group names.
|
---|
94 | *
|
---|
95 | * Must correspond 100% to RTLOGGROUP!
|
---|
96 | * Don't forget commas!
|
---|
97 | *
|
---|
98 | * @remark It should be pretty obvious, but just to have
|
---|
99 | * mentioned it, the values are sorted alphabetically (using the
|
---|
100 | * english alphabet) except for _DEFAULT which is always first.
|
---|
101 | *
|
---|
102 | * If anyone might be wondering what the alphabet looks like:
|
---|
103 | * a b c d e f g h i j k l m n o p q r s t u v w x y z
|
---|
104 | *
|
---|
105 | * The RT_XX log group names are placeholders for new modules being added,
|
---|
106 | * to make sure that there always is a total of 32 log group entries.
|
---|
107 | */
|
---|
108 | #define RT_LOGGROUP_NAMES \
|
---|
109 | "DEFAULT", \
|
---|
110 | "RT_CRYPTO", \
|
---|
111 | "RT_DBG", \
|
---|
112 | "RT_DBG_DWARF", \
|
---|
113 | "RT_DIR", \
|
---|
114 | "RT_FDT", \
|
---|
115 | "RT_FILE", \
|
---|
116 | "RT_FS", \
|
---|
117 | "RT_FTP", \
|
---|
118 | "RT_HTTP", \
|
---|
119 | "RT_IOQUEUE", \
|
---|
120 | "RT_LDR", \
|
---|
121 | "RT_LOCALIPC", \
|
---|
122 | "RT_PATH", \
|
---|
123 | "RT_PROCESS", \
|
---|
124 | "RT_REST", \
|
---|
125 | "RT_SYMLINK", \
|
---|
126 | "RT_THREAD", \
|
---|
127 | "RT_TIME", \
|
---|
128 | "RT_TIMER", \
|
---|
129 | "RT_VFS", \
|
---|
130 | "RT_21", \
|
---|
131 | "RT_22", \
|
---|
132 | "RT_23", \
|
---|
133 | "RT_24", \
|
---|
134 | "RT_25", \
|
---|
135 | "RT_26", \
|
---|
136 | "RT_27", \
|
---|
137 | "RT_28", \
|
---|
138 | "RT_29", \
|
---|
139 | "RT_30", \
|
---|
140 | "RT_ZIP"
|
---|
141 |
|
---|
142 |
|
---|
143 | /** @def LOG_GROUP
|
---|
144 | * Active logging group.
|
---|
145 | */
|
---|
146 | #ifndef LOG_GROUP
|
---|
147 | # define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | /** @def LOG_FN_FMT
|
---|
151 | * You can use this to specify your desired way of printing __PRETTY_FUNCTION__
|
---|
152 | * if you dislike the default one.
|
---|
153 | */
|
---|
154 | #ifndef LOG_FN_FMT
|
---|
155 | # define LOG_FN_FMT "%Rfn"
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | #ifdef LOG_INSTANCE
|
---|
159 | # error "LOG_INSTANCE is no longer supported."
|
---|
160 | #endif
|
---|
161 | #ifdef LOG_REL_INSTANCE
|
---|
162 | # error "LOG_REL_INSTANCE is no longer supported."
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | /** Logger structure. */
|
---|
166 | typedef struct RTLOGGER RTLOGGER;
|
---|
167 | /** Pointer to logger structure. */
|
---|
168 | typedef RTLOGGER *PRTLOGGER;
|
---|
169 | /** Pointer to const logger structure. */
|
---|
170 | typedef const RTLOGGER *PCRTLOGGER;
|
---|
171 |
|
---|
172 |
|
---|
173 | /** Pointer to a log buffer descriptor. */
|
---|
174 | typedef struct RTLOGBUFFERDESC *PRTLOGBUFFERDESC;
|
---|
175 |
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Logger phase.
|
---|
179 | *
|
---|
180 | * Used for signalling the log header/footer callback what to do.
|
---|
181 | */
|
---|
182 | typedef enum RTLOGPHASE
|
---|
183 | {
|
---|
184 | /** Begin of the logging. */
|
---|
185 | RTLOGPHASE_BEGIN = 0,
|
---|
186 | /** End of the logging. */
|
---|
187 | RTLOGPHASE_END,
|
---|
188 | /** Before rotating the log file. */
|
---|
189 | RTLOGPHASE_PREROTATE,
|
---|
190 | /** After rotating the log file. */
|
---|
191 | RTLOGPHASE_POSTROTATE,
|
---|
192 | /** 32-bit type blow up hack. */
|
---|
193 | RTLOGPHASE_32BIT_HACK = 0x7fffffff
|
---|
194 | } RTLOGPHASE;
|
---|
195 |
|
---|
196 |
|
---|
197 | #if 0 /* retired */
|
---|
198 | /**
|
---|
199 | * Logger function.
|
---|
200 | *
|
---|
201 | * @param pszFormat Format string.
|
---|
202 | * @param ... Optional arguments as specified in the format string.
|
---|
203 | */
|
---|
204 | typedef DECLCALLBACKTYPE(void, FNRTLOGGER,(const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
205 | /** Pointer to logger function. */
|
---|
206 | typedef FNRTLOGGER *PFNRTLOGGER;
|
---|
207 | #endif
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Custom buffer flushing function.
|
---|
211 | *
|
---|
212 | * @retval true if flushed and the buffer can be reused.
|
---|
213 | * @retval false for switching to the next buffer because an async flush of
|
---|
214 | * @a pBufDesc is still pending. The implementation is responsible for
|
---|
215 | * only returning when the next buffer is ready for reuse, the generic
|
---|
216 | * logger code has no facility to make sure of this.
|
---|
217 | *
|
---|
218 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
219 | * @param pBufDesc The descriptor of the buffer to be flushed.
|
---|
220 | */
|
---|
221 | typedef DECLCALLBACKTYPE(bool, FNRTLOGFLUSH,(PRTLOGGER pLogger, PRTLOGBUFFERDESC pBufDesc));
|
---|
222 | /** Pointer to flush function. */
|
---|
223 | typedef FNRTLOGFLUSH *PFNRTLOGFLUSH;
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * Header/footer message callback.
|
---|
227 | *
|
---|
228 | * @param pLogger Pointer to the logger instance.
|
---|
229 | * @param pszFormat Format string.
|
---|
230 | * @param ... Optional arguments specified in the format string.
|
---|
231 | */
|
---|
232 | typedef DECLCALLBACKTYPE(void, FNRTLOGPHASEMSG,(PRTLOGGER pLogger, const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(2, 3);
|
---|
233 | /** Pointer to header/footer message callback function. */
|
---|
234 | typedef FNRTLOGPHASEMSG *PFNRTLOGPHASEMSG;
|
---|
235 |
|
---|
236 | /**
|
---|
237 | * Log file header/footer callback.
|
---|
238 | *
|
---|
239 | * @param pLogger Pointer to the logger instance.
|
---|
240 | * @param enmLogPhase Indicates at what time the callback is invoked.
|
---|
241 | * @param pfnLogPhaseMsg Callback for writing the header/footer (RTLogPrintf
|
---|
242 | * and others are out of bounds).
|
---|
243 | */
|
---|
244 | typedef DECLCALLBACKTYPE(void, FNRTLOGPHASE,(PRTLOGGER pLogger, RTLOGPHASE enmLogPhase, PFNRTLOGPHASEMSG pfnLogPhaseMsg));
|
---|
245 | /** Pointer to log header/footer callback function. */
|
---|
246 | typedef FNRTLOGPHASE *PFNRTLOGPHASE;
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * Custom log prefix callback.
|
---|
250 | *
|
---|
251 | *
|
---|
252 | * @returns The number of chars written.
|
---|
253 | *
|
---|
254 | * @param pLogger Pointer to the logger instance.
|
---|
255 | * @param pchBuf Output buffer pointer.
|
---|
256 | * No need to terminate the output.
|
---|
257 | * @param cchBuf The size of the output buffer.
|
---|
258 | * @param pvUser The user argument.
|
---|
259 | */
|
---|
260 | typedef DECLCALLBACKTYPE(size_t, FNRTLOGPREFIX,(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser));
|
---|
261 | /** Pointer to prefix callback function. */
|
---|
262 | typedef FNRTLOGPREFIX *PFNRTLOGPREFIX;
|
---|
263 |
|
---|
264 |
|
---|
265 | /** Pointer to a constant log output interface. */
|
---|
266 | typedef const struct RTLOGOUTPUTIF *PCRTLOGOUTPUTIF;
|
---|
267 |
|
---|
268 | /**
|
---|
269 | * Logging output interface.
|
---|
270 | */
|
---|
271 | typedef struct RTLOGOUTPUTIF
|
---|
272 | {
|
---|
273 | /**
|
---|
274 | * Opens a new log file with the given name.
|
---|
275 | *
|
---|
276 | * @returns IPRT status code.
|
---|
277 | * @param pIf Pointer to this interface.
|
---|
278 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
279 | * @param pszFilename The filename to open.
|
---|
280 | * @param fFlags Open flags, combination of RTFILE_O_XXX.
|
---|
281 | */
|
---|
282 | DECLR3CALLBACKMEMBER(int, pfnOpen, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags));
|
---|
283 |
|
---|
284 | /**
|
---|
285 | * Closes the currently open file.
|
---|
286 | *
|
---|
287 | * @returns IPRT status code.
|
---|
288 | * @param pIf Pointer to this interface.
|
---|
289 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
290 | */
|
---|
291 | DECLR3CALLBACKMEMBER(int, pfnClose, (PCRTLOGOUTPUTIF pIf, void *pvUser));
|
---|
292 |
|
---|
293 | /**
|
---|
294 | * Deletes the given file.
|
---|
295 | *
|
---|
296 | * @returns IPRT status code.
|
---|
297 | * @param pIf Pointer to this interface.
|
---|
298 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
299 | * @param pszFilename The filename to delete.
|
---|
300 | */
|
---|
301 | DECLR3CALLBACKMEMBER(int, pfnDelete, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename));
|
---|
302 |
|
---|
303 | /**
|
---|
304 | * Renames the given file.
|
---|
305 | *
|
---|
306 | * @returns IPRT status code.
|
---|
307 | * @param pIf Pointer to this interface.
|
---|
308 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
309 | * @param pszFilenameOld The old filename to rename.
|
---|
310 | * @param pszFilenameNew The new filename.
|
---|
311 | * @param fFlags Flags for the operation, combination of RTFILEMOVE_FLAGS_XXX.
|
---|
312 | */
|
---|
313 | DECLR3CALLBACKMEMBER(int, pfnRename, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld,
|
---|
314 | const char *pszFilenameNew, uint32_t fFlags));
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Queries the size of the log file.
|
---|
318 | *
|
---|
319 | * @returns IPRT status code.
|
---|
320 | * @param pIf Pointer to this interface.
|
---|
321 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
322 | * @param pcbFile Where to store the file size in bytes on success.
|
---|
323 | */
|
---|
324 | DECLR3CALLBACKMEMBER(int, pfnQuerySize, (PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize));
|
---|
325 |
|
---|
326 | /**
|
---|
327 | * Writes data to the log file.
|
---|
328 | *
|
---|
329 | * @returns IPRT status code.
|
---|
330 | * @param pIf Pointer to this interface.
|
---|
331 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
332 | * @param pvBuf The data to write.
|
---|
333 | * @param cbWrite Number of bytes to write.
|
---|
334 | * @param pcbWritten Where to store the actual number of bytes written on success.
|
---|
335 | */
|
---|
336 | DECLR3CALLBACKMEMBER(int, pfnWrite, (PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf,
|
---|
337 | size_t cbWrite, size_t *pcbWritten));
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * Flushes data to the underlying storage medium.
|
---|
341 | *
|
---|
342 | * @returns IPRT status code.
|
---|
343 | * @param pIf Pointer to this interface.
|
---|
344 | * @param pvUser Opaque user data passed when setting the callbacks.
|
---|
345 | */
|
---|
346 | DECLR3CALLBACKMEMBER(int, pfnFlush, (PCRTLOGOUTPUTIF pIf, void *pvUser));
|
---|
347 | } RTLOGOUTPUTIF;
|
---|
348 | /** Pointer to a logging output interface. */
|
---|
349 | typedef struct RTLOGOUTPUTIF *PRTLOGOUTPUTIF;
|
---|
350 |
|
---|
351 |
|
---|
352 | /**
|
---|
353 | * Auxiliary buffer descriptor.
|
---|
354 | *
|
---|
355 | * This is what we share we ring-3 and use for flushing ring-0 EMT loggers when
|
---|
356 | * we return to ring-3.
|
---|
357 | */
|
---|
358 | typedef struct RTLOGBUFFERAUXDESC
|
---|
359 | {
|
---|
360 | /** Flush indicator.
|
---|
361 | * Ring-3 sets this if it flushed the buffer, ring-0 clears it again after
|
---|
362 | * writing. */
|
---|
363 | bool volatile fFlushedIndicator;
|
---|
364 | bool afPadding[3];
|
---|
365 | /** Copy of RTLOGBUFFERDESC::offBuf. */
|
---|
366 | uint32_t offBuf;
|
---|
367 | } RTLOGBUFFERAUXDESC;
|
---|
368 | /** Pointer to auxiliary buffer descriptor. */
|
---|
369 | typedef RTLOGBUFFERAUXDESC *PRTLOGBUFFERAUXDESC;
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Log buffer desciptor.
|
---|
373 | */
|
---|
374 | typedef struct RTLOGBUFFERDESC
|
---|
375 | {
|
---|
376 | /** Magic value / eye catcher (RTLOGBUFFERDESC_MAGIC). */
|
---|
377 | uint32_t u32Magic;
|
---|
378 | /** Padding. */
|
---|
379 | uint32_t uReserved;
|
---|
380 | /** The buffer size. */
|
---|
381 | uint32_t cbBuf;
|
---|
382 | /** The current buffer offset. */
|
---|
383 | uint32_t offBuf;
|
---|
384 | /** Pointer to the buffer. */
|
---|
385 | char *pchBuf;
|
---|
386 | /** Pointer to auxiliary desciptor, NULL if not used. */
|
---|
387 | PRTLOGBUFFERAUXDESC pAux;
|
---|
388 | } RTLOGBUFFERDESC;
|
---|
389 |
|
---|
390 | /** RTLOGBUFFERDESC::u32Magic value. (Avram Noam Chomsky) */
|
---|
391 | #define RTLOGBUFFERDESC_MAGIC UINT32_C(0x19281207)
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * The public logger instance part.
|
---|
395 | *
|
---|
396 | * The logger instance is mostly abstract and kept as RTLOGGERINTERNAL within
|
---|
397 | * log.cpp. This public part is at the start of RTLOGGERINTERNAL.
|
---|
398 | */
|
---|
399 | struct RTLOGGER
|
---|
400 | {
|
---|
401 | /** Magic number (RTLOGGER_MAGIC). */
|
---|
402 | uint32_t u32Magic;
|
---|
403 | /** User value \#1, initialized to zero. */
|
---|
404 | uint32_t u32UserValue1;
|
---|
405 | /** User value \#2, initialized to zero. */
|
---|
406 | uint64_t u64UserValue2;
|
---|
407 | /** User value \#3, initialized to zero. */
|
---|
408 | uint64_t u64UserValue3;
|
---|
409 | #if 0
|
---|
410 | /** Pointer to the logger function (used in non-C99 mode only).
|
---|
411 | *
|
---|
412 | * This is actually pointer to a wrapper/stub function which will push a pointer
|
---|
413 | * to the instance pointer onto the stack before jumping to the real logger
|
---|
414 | * function. A very unfortunate hack to work around the missing variadic macro
|
---|
415 | * support in older C++/C standards. (The memory is allocated using
|
---|
416 | * RTMemExecAlloc(), except for agnostic R0 code.) */
|
---|
417 | PFNRTLOGGER pfnLogger;
|
---|
418 | #else
|
---|
419 | /** Unused. */
|
---|
420 | uintptr_t uUsedToBeNonC99Logger;
|
---|
421 | #endif
|
---|
422 | #if ARCH_BITS == 32
|
---|
423 | /** Explicit padding. */
|
---|
424 | uint32_t uReserved1;
|
---|
425 | #endif
|
---|
426 | };
|
---|
427 |
|
---|
428 | /** RTLOGGER::u32Magic value. (John Rogers Searle) */
|
---|
429 | #define RTLOGGER_MAGIC UINT32_C(0x19320731)
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * Logger flags.
|
---|
433 | */
|
---|
434 | typedef enum RTLOGFLAGS
|
---|
435 | {
|
---|
436 | /** The logger instance is disabled for normal output. */
|
---|
437 | RTLOGFLAGS_DISABLED = 0x00000001,
|
---|
438 | /** The logger instance is using buffered output. */
|
---|
439 | RTLOGFLAGS_BUFFERED = 0x00000002,
|
---|
440 | /** The logger instance expands LF to CR/LF. */
|
---|
441 | RTLOGFLAGS_USECRLF = 0x00000010,
|
---|
442 | /** Append to the log destination where applicable. */
|
---|
443 | RTLOGFLAGS_APPEND = 0x00000020,
|
---|
444 | /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
445 | RTLOGFLAGS_REL_TS = 0x00000040,
|
---|
446 | /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
447 | RTLOGFLAGS_DECIMAL_TS = 0x00000080,
|
---|
448 | /** Open the file in write through mode. */
|
---|
449 | RTLOGFLAGS_WRITE_THROUGH = 0x00000100,
|
---|
450 | /** Flush the file to disk when flushing the buffer. */
|
---|
451 | RTLOGFLAGS_FLUSH = 0x00000200,
|
---|
452 | /** Restrict the number of log entries per group. */
|
---|
453 | RTLOGFLAGS_RESTRICT_GROUPS = 0x00000400,
|
---|
454 | /** New lines should be prefixed with the write and read lock counts. */
|
---|
455 | RTLOGFLAGS_PREFIX_LOCK_COUNTS = 0x00008000,
|
---|
456 | /** New lines should be prefixed with the CPU id (ApicID on intel/amd). */
|
---|
457 | RTLOGFLAGS_PREFIX_CPUID = 0x00010000,
|
---|
458 | /** New lines should be prefixed with the native process id. */
|
---|
459 | RTLOGFLAGS_PREFIX_PID = 0x00020000,
|
---|
460 | /** New lines should be prefixed with group flag number causing the output. */
|
---|
461 | RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,
|
---|
462 | /** New lines should be prefixed with group flag name causing the output. */
|
---|
463 | RTLOGFLAGS_PREFIX_FLAG = 0x00080000,
|
---|
464 | /** New lines should be prefixed with group number. */
|
---|
465 | RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,
|
---|
466 | /** New lines should be prefixed with group name. */
|
---|
467 | RTLOGFLAGS_PREFIX_GROUP = 0x00200000,
|
---|
468 | /** New lines should be prefixed with the native thread id. */
|
---|
469 | RTLOGFLAGS_PREFIX_TID = 0x00400000,
|
---|
470 | /** New lines should be prefixed with thread name. */
|
---|
471 | RTLOGFLAGS_PREFIX_THREAD = 0x00800000,
|
---|
472 | /** New lines should be prefixed with data from a custom callback. */
|
---|
473 | RTLOGFLAGS_PREFIX_CUSTOM = 0x01000000,
|
---|
474 | /** New lines should be prefixed with formatted timestamp since program start. */
|
---|
475 | RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
|
---|
476 | /** New lines should be prefixed with formatted timestamp (UCT). */
|
---|
477 | RTLOGFLAGS_PREFIX_TIME = 0x08000000,
|
---|
478 | /** New lines should be prefixed with milliseconds since program start. */
|
---|
479 | RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,
|
---|
480 | /** New lines should be prefixed with timestamp. */
|
---|
481 | RTLOGFLAGS_PREFIX_TSC = 0x20000000,
|
---|
482 | /** New lines should be prefixed with timestamp. */
|
---|
483 | RTLOGFLAGS_PREFIX_TS = 0x40000000,
|
---|
484 | /** The prefix mask. */
|
---|
485 | RTLOGFLAGS_PREFIX_MASK = 0x7dff8000
|
---|
486 | } RTLOGFLAGS;
|
---|
487 | /** Don't use locking. */
|
---|
488 | #define RTLOG_F_NO_LOCKING RT_BIT_64(63)
|
---|
489 | /** Mask with all valid log flags (for validation). */
|
---|
490 | #define RTLOG_F_VALID_MASK UINT64_C(0x800000007fff87f3)
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Logger per group flags.
|
---|
494 | *
|
---|
495 | * @remarks We only use the lower 16 bits here. We'll be combining it with the
|
---|
496 | * group number in a few places.
|
---|
497 | */
|
---|
498 | typedef enum RTLOGGRPFLAGS
|
---|
499 | {
|
---|
500 | /** Enabled. */
|
---|
501 | RTLOGGRPFLAGS_ENABLED = 0x0001,
|
---|
502 | /** Flow logging. */
|
---|
503 | RTLOGGRPFLAGS_FLOW = 0x0002,
|
---|
504 | /** Warnings logging. */
|
---|
505 | RTLOGGRPFLAGS_WARN = 0x0004,
|
---|
506 | /* 0x0008 for later. */
|
---|
507 | /** Level 1 logging. */
|
---|
508 | RTLOGGRPFLAGS_LEVEL_1 = 0x0010,
|
---|
509 | /** Level 2 logging. */
|
---|
510 | RTLOGGRPFLAGS_LEVEL_2 = 0x0020,
|
---|
511 | /** Level 3 logging. */
|
---|
512 | RTLOGGRPFLAGS_LEVEL_3 = 0x0040,
|
---|
513 | /** Level 4 logging. */
|
---|
514 | RTLOGGRPFLAGS_LEVEL_4 = 0x0080,
|
---|
515 | /** Level 5 logging. */
|
---|
516 | RTLOGGRPFLAGS_LEVEL_5 = 0x0100,
|
---|
517 | /** Level 6 logging. */
|
---|
518 | RTLOGGRPFLAGS_LEVEL_6 = 0x0200,
|
---|
519 | /** Level 7 logging. */
|
---|
520 | RTLOGGRPFLAGS_LEVEL_7 = 0x0400,
|
---|
521 | /** Level 8 logging. */
|
---|
522 | RTLOGGRPFLAGS_LEVEL_8 = 0x0800,
|
---|
523 | /** Level 9 logging. */
|
---|
524 | RTLOGGRPFLAGS_LEVEL_9 = 0x1000,
|
---|
525 | /** Level 10 logging. */
|
---|
526 | RTLOGGRPFLAGS_LEVEL_10 = 0x2000,
|
---|
527 | /** Level 11 logging. */
|
---|
528 | RTLOGGRPFLAGS_LEVEL_11 = 0x4000,
|
---|
529 | /** Level 12 logging. */
|
---|
530 | RTLOGGRPFLAGS_LEVEL_12 = 0x8000,
|
---|
531 |
|
---|
532 | /** Restrict the number of log entries. */
|
---|
533 | RTLOGGRPFLAGS_RESTRICT = 0x40000000,
|
---|
534 | /** Blow up the type. */
|
---|
535 | RTLOGGRPFLAGS_32BIT_HACK = 0x7fffffff
|
---|
536 | } RTLOGGRPFLAGS;
|
---|
537 |
|
---|
538 | /**
|
---|
539 | * Logger destination types and flags.
|
---|
540 | */
|
---|
541 | typedef enum RTLOGDEST
|
---|
542 | {
|
---|
543 | /** Log to file. */
|
---|
544 | RTLOGDEST_FILE = 0x00000001,
|
---|
545 | /** Log to stdout. */
|
---|
546 | RTLOGDEST_STDOUT = 0x00000002,
|
---|
547 | /** Log to stderr. */
|
---|
548 | RTLOGDEST_STDERR = 0x00000004,
|
---|
549 | /** Log to debugger (win32 only). */
|
---|
550 | RTLOGDEST_DEBUGGER = 0x00000008,
|
---|
551 | /** Log to com port. */
|
---|
552 | RTLOGDEST_COM = 0x00000010,
|
---|
553 | /** Log a memory ring buffer. */
|
---|
554 | RTLOGDEST_RINGBUF = 0x00000020,
|
---|
555 | /** The parent VMM debug log. */
|
---|
556 | RTLOGDEST_VMM = 0x00000040,
|
---|
557 | /** The parent VMM release log. */
|
---|
558 | RTLOGDEST_VMM_REL = 0x00000080,
|
---|
559 | /** Open files with no deny (share read, write, delete) on Windows. */
|
---|
560 | RTLOGDEST_F_NO_DENY = 0x00010000,
|
---|
561 | /** Delay opening the log file, logging to the buffer untill
|
---|
562 | * RTLogClearFileDelayFlag is called. */
|
---|
563 | RTLOGDEST_F_DELAY_FILE = 0x00020000,
|
---|
564 | /** Don't allow changes to the filename or mode of opening it. */
|
---|
565 | RTLOGDEST_FIXED_FILE = 0x01000000,
|
---|
566 | /** Don't allow changing the directory. */
|
---|
567 | RTLOGDEST_FIXED_DIR = 0x02000000,
|
---|
568 | /** Just a dummy flag to be used when no other flag applies. */
|
---|
569 | RTLOGDEST_DUMMY = 0x20000000,
|
---|
570 | /** Log to a user defined output stream. */
|
---|
571 | RTLOGDEST_USER = 0x40000000
|
---|
572 | } RTLOGDEST;
|
---|
573 | /** Valid log destinations. */
|
---|
574 | #define RTLOG_DST_VALID_MASK UINT32_C(0x630300ff)
|
---|
575 | /** Log destinations that can be changed via RTLogChangeDestinations. */
|
---|
576 | #define RTLOG_DST_CHANGE_MASK UINT32_C(0x400000de)
|
---|
577 |
|
---|
578 |
|
---|
579 | #ifdef DOXYGEN_RUNNING
|
---|
580 | # define LOG_DISABLED
|
---|
581 | # define LOG_ENABLED
|
---|
582 | # define LOG_ENABLE_FLOW
|
---|
583 | #endif
|
---|
584 |
|
---|
585 | /** @def LOG_DISABLED
|
---|
586 | * Use this compile time define to disable all logging macros. It can
|
---|
587 | * be overridden for each of the logging macros by the LOG_ENABLE*
|
---|
588 | * compile time defines.
|
---|
589 | */
|
---|
590 |
|
---|
591 | /** @def LOG_ENABLED
|
---|
592 | * Use this compile time define to enable logging when not in debug mode
|
---|
593 | * or LOG_DISABLED is set.
|
---|
594 | * This will enable Log() only.
|
---|
595 | */
|
---|
596 |
|
---|
597 | /** @def LOG_ENABLE_FLOW
|
---|
598 | * Use this compile time define to enable flow logging when not in
|
---|
599 | * debug mode or LOG_DISABLED is defined.
|
---|
600 | * This will enable LogFlow() only.
|
---|
601 | */
|
---|
602 |
|
---|
603 | /*
|
---|
604 | * Determine whether logging is enabled and forcefully normalize the indicators.
|
---|
605 | */
|
---|
606 | #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
|
---|
607 | # undef LOG_DISABLED
|
---|
608 | # undef LOG_ENABLED
|
---|
609 | # define LOG_ENABLED
|
---|
610 | #else
|
---|
611 | # undef LOG_ENABLED
|
---|
612 | # undef LOG_DISABLED
|
---|
613 | # define LOG_DISABLED
|
---|
614 | #endif
|
---|
615 |
|
---|
616 |
|
---|
617 | /** @def LOG_USE_C99
|
---|
618 | * Governs the use of variadic macros.
|
---|
619 | */
|
---|
620 | #ifndef LOG_USE_C99
|
---|
621 | # define LOG_USE_C99
|
---|
622 | #endif
|
---|
623 |
|
---|
624 |
|
---|
625 | /** @name Macros for checking whether a log level is enabled.
|
---|
626 | * @{ */
|
---|
627 | /** @def LogIsItEnabled
|
---|
628 | * Checks whether the specified logging group is enabled or not.
|
---|
629 | */
|
---|
630 | #ifdef LOG_ENABLED
|
---|
631 | # define LogIsItEnabled(a_fFlags, a_iGroup) ( RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
|
---|
632 | #else
|
---|
633 | # define LogIsItEnabled(a_fFlags, a_iGroup) (false)
|
---|
634 | #endif
|
---|
635 |
|
---|
636 | /** @def LogIsEnabled
|
---|
637 | * Checks whether level 1 logging is enabled.
|
---|
638 | */
|
---|
639 | #define LogIsEnabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
640 |
|
---|
641 | /** @def LogIs2Enabled
|
---|
642 | * Checks whether level 2 logging is enabled.
|
---|
643 | */
|
---|
644 | #define LogIs2Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
645 |
|
---|
646 | /** @def LogIs3Enabled
|
---|
647 | * Checks whether level 3 logging is enabled.
|
---|
648 | */
|
---|
649 | #define LogIs3Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
650 |
|
---|
651 | /** @def LogIs4Enabled
|
---|
652 | * Checks whether level 4 logging is enabled.
|
---|
653 | */
|
---|
654 | #define LogIs4Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
655 |
|
---|
656 | /** @def LogIs5Enabled
|
---|
657 | * Checks whether level 5 logging is enabled.
|
---|
658 | */
|
---|
659 | #define LogIs5Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
660 |
|
---|
661 | /** @def LogIs6Enabled
|
---|
662 | * Checks whether level 6 logging is enabled.
|
---|
663 | */
|
---|
664 | #define LogIs6Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
665 |
|
---|
666 | /** @def LogIs7Enabled
|
---|
667 | * Checks whether level 7 logging is enabled.
|
---|
668 | */
|
---|
669 | #define LogIs7Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
|
---|
670 |
|
---|
671 | /** @def LogIs8Enabled
|
---|
672 | * Checks whether level 8 logging is enabled.
|
---|
673 | */
|
---|
674 | #define LogIs8Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
|
---|
675 |
|
---|
676 | /** @def LogIs9Enabled
|
---|
677 | * Checks whether level 9 logging is enabled.
|
---|
678 | */
|
---|
679 | #define LogIs9Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
|
---|
680 |
|
---|
681 | /** @def LogIs10Enabled
|
---|
682 | * Checks whether level 10 logging is enabled.
|
---|
683 | */
|
---|
684 | #define LogIs10Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
|
---|
685 |
|
---|
686 | /** @def LogIs11Enabled
|
---|
687 | * Checks whether level 11 logging is enabled.
|
---|
688 | */
|
---|
689 | #define LogIs11Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
|
---|
690 |
|
---|
691 | /** @def LogIs12Enabled
|
---|
692 | * Checks whether level 12 logging is enabled.
|
---|
693 | */
|
---|
694 | #define LogIs12Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
|
---|
695 |
|
---|
696 | /** @def LogIsFlowEnabled
|
---|
697 | * Checks whether execution flow logging is enabled.
|
---|
698 | */
|
---|
699 | #define LogIsFlowEnabled() LogIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
700 |
|
---|
701 | /** @def LogIsWarnEnabled
|
---|
702 | * Checks whether execution flow logging is enabled.
|
---|
703 | */
|
---|
704 | #define LogIsWarnEnabled() LogIsItEnabled(RTLOGGRPFLAGS_WARN, LOG_GROUP)
|
---|
705 | /** @} */
|
---|
706 |
|
---|
707 |
|
---|
708 | /** @def LogIt
|
---|
709 | * Write to specific logger if group enabled.
|
---|
710 | */
|
---|
711 | #ifdef LOG_ENABLED
|
---|
712 | # if defined(LOG_USE_C99)
|
---|
713 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
714 | # define _LogIt(a_fFlags, a_iGroup, ...) \
|
---|
715 | do \
|
---|
716 | { \
|
---|
717 | PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
718 | if (RT_LIKELY(!LogIt_pLogger)) \
|
---|
719 | { /* likely */ } \
|
---|
720 | else \
|
---|
721 | RTLogLoggerEx(LogIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
722 | } while (0)
|
---|
723 | # define LogIt(a_fFlags, a_iGroup, fmtargs) _LogIt(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
|
---|
724 | # define _LogItAlways(a_fFlags, a_iGroup, ...) RTLogLoggerEx(NULL, a_fFlags, UINT32_MAX, __VA_ARGS__)
|
---|
725 | # define LogItAlways(a_fFlags, a_iGroup, fmtargs) _LogItAlways(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
|
---|
726 | /** @todo invent a flag or something for skipping the group check so we can pass iGroup. LogItAlways. */
|
---|
727 | # else
|
---|
728 | # define LogIt(a_fFlags, a_iGroup, fmtargs) \
|
---|
729 | do \
|
---|
730 | { \
|
---|
731 | PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
732 | if (RT_LIKELY(!LogIt_pLogger)) \
|
---|
733 | { /* likely */ } \
|
---|
734 | else \
|
---|
735 | { \
|
---|
736 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
737 | } \
|
---|
738 | } while (0)
|
---|
739 | # define LogItAlways(a_fFlags, a_iGroup, fmtargs) \
|
---|
740 | do \
|
---|
741 | { \
|
---|
742 | PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(0, UINT16_MAX)); \
|
---|
743 | if (LogIt_pLogger) \
|
---|
744 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
745 | } while (0)
|
---|
746 | # endif
|
---|
747 | #else
|
---|
748 | # define LogIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
749 | # define LogItAlways(a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
750 | # if defined(LOG_USE_C99)
|
---|
751 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
752 | # define _LogIt(a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
753 | # define _LogItAlways(a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
754 | # endif
|
---|
755 | #endif
|
---|
756 |
|
---|
757 |
|
---|
758 | /** @name Basic logging macros
|
---|
759 | * @{ */
|
---|
760 | /** @def Log
|
---|
761 | * Level 1 logging that works regardless of the group settings.
|
---|
762 | */
|
---|
763 | #define LogAlways(a) LogItAlways(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
764 |
|
---|
765 | /** @def Log
|
---|
766 | * Level 1 logging.
|
---|
767 | */
|
---|
768 | #define Log(a) LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
769 |
|
---|
770 | /** @def Log2
|
---|
771 | * Level 2 logging.
|
---|
772 | */
|
---|
773 | #define Log2(a) LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
774 |
|
---|
775 | /** @def Log3
|
---|
776 | * Level 3 logging.
|
---|
777 | */
|
---|
778 | #define Log3(a) LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
779 |
|
---|
780 | /** @def Log4
|
---|
781 | * Level 4 logging.
|
---|
782 | */
|
---|
783 | #define Log4(a) LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
784 |
|
---|
785 | /** @def Log5
|
---|
786 | * Level 5 logging.
|
---|
787 | */
|
---|
788 | #define Log5(a) LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
789 |
|
---|
790 | /** @def Log6
|
---|
791 | * Level 6 logging.
|
---|
792 | */
|
---|
793 | #define Log6(a) LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
794 |
|
---|
795 | /** @def Log7
|
---|
796 | * Level 7 logging.
|
---|
797 | */
|
---|
798 | #define Log7(a) LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
|
---|
799 |
|
---|
800 | /** @def Log8
|
---|
801 | * Level 8 logging.
|
---|
802 | */
|
---|
803 | #define Log8(a) LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
|
---|
804 |
|
---|
805 | /** @def Log9
|
---|
806 | * Level 9 logging.
|
---|
807 | */
|
---|
808 | #define Log9(a) LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
|
---|
809 |
|
---|
810 | /** @def Log10
|
---|
811 | * Level 10 logging.
|
---|
812 | */
|
---|
813 | #define Log10(a) LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
|
---|
814 |
|
---|
815 | /** @def Log11
|
---|
816 | * Level 11 logging.
|
---|
817 | */
|
---|
818 | #define Log11(a) LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
|
---|
819 |
|
---|
820 | /** @def Log12
|
---|
821 | * Level 12 logging.
|
---|
822 | */
|
---|
823 | #define Log12(a) LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
|
---|
824 |
|
---|
825 | /** @def LogFlow
|
---|
826 | * Logging of execution flow.
|
---|
827 | */
|
---|
828 | #define LogFlow(a) LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
829 |
|
---|
830 | /** @def LogWarn
|
---|
831 | * Logging of warnings.
|
---|
832 | */
|
---|
833 | #define LogWarn(a) LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
|
---|
834 | /** @} */
|
---|
835 |
|
---|
836 |
|
---|
837 | /** @name Logging macros prefixing the current function name.
|
---|
838 | * @{ */
|
---|
839 | /** @def LogFunc
|
---|
840 | * Level 1 logging inside C/C++ functions.
|
---|
841 | *
|
---|
842 | * Prepends the given log message with the function name followed by a
|
---|
843 | * semicolon and space.
|
---|
844 | *
|
---|
845 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
846 | */
|
---|
847 | #ifdef LOG_USE_C99
|
---|
848 | # define LogFunc(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
849 | #else
|
---|
850 | # define LogFunc(a) do { Log((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
851 | #endif
|
---|
852 |
|
---|
853 | /** @def Log2Func
|
---|
854 | * Level 2 logging inside C/C++ functions.
|
---|
855 | *
|
---|
856 | * Prepends the given log message with the function name followed by a
|
---|
857 | * semicolon and space.
|
---|
858 | *
|
---|
859 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
860 | */
|
---|
861 | #ifdef LOG_USE_C99
|
---|
862 | # define Log2Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
863 | #else
|
---|
864 | # define Log2Func(a) do { Log2((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
|
---|
865 | #endif
|
---|
866 |
|
---|
867 | /** @def Log3Func
|
---|
868 | * Level 3 logging inside C/C++ functions.
|
---|
869 | *
|
---|
870 | * Prepends the given log message with the function name followed by a
|
---|
871 | * semicolon and space.
|
---|
872 | *
|
---|
873 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
874 | */
|
---|
875 | #ifdef LOG_USE_C99
|
---|
876 | # define Log3Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
877 | #else
|
---|
878 | # define Log3Func(a) do { Log3((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
|
---|
879 | #endif
|
---|
880 |
|
---|
881 | /** @def Log4Func
|
---|
882 | * Level 4 logging inside C/C++ functions.
|
---|
883 | *
|
---|
884 | * Prepends the given log message with the function name followed by a
|
---|
885 | * semicolon and space.
|
---|
886 | *
|
---|
887 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
888 | */
|
---|
889 | #ifdef LOG_USE_C99
|
---|
890 | # define Log4Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
891 | #else
|
---|
892 | # define Log4Func(a) do { Log4((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
|
---|
893 | #endif
|
---|
894 |
|
---|
895 | /** @def Log5Func
|
---|
896 | * Level 5 logging inside C/C++ functions.
|
---|
897 | *
|
---|
898 | * Prepends the given log message with the function name followed by a
|
---|
899 | * semicolon and space.
|
---|
900 | *
|
---|
901 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
902 | */
|
---|
903 | #ifdef LOG_USE_C99
|
---|
904 | # define Log5Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
905 | #else
|
---|
906 | # define Log5Func(a) do { Log5((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
|
---|
907 | #endif
|
---|
908 |
|
---|
909 | /** @def Log6Func
|
---|
910 | * Level 6 logging inside C/C++ functions.
|
---|
911 | *
|
---|
912 | * Prepends the given log message with the function name followed by a
|
---|
913 | * semicolon and space.
|
---|
914 | *
|
---|
915 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
916 | */
|
---|
917 | #ifdef LOG_USE_C99
|
---|
918 | # define Log6Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
919 | #else
|
---|
920 | # define Log6Func(a) do { Log6((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
|
---|
921 | #endif
|
---|
922 |
|
---|
923 | /** @def Log7Func
|
---|
924 | * Level 7 logging inside C/C++ functions.
|
---|
925 | *
|
---|
926 | * Prepends the given log message with the function name followed by a
|
---|
927 | * semicolon and space.
|
---|
928 | *
|
---|
929 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
930 | */
|
---|
931 | #ifdef LOG_USE_C99
|
---|
932 | # define Log7Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
933 | #else
|
---|
934 | # define Log7Func(a) do { Log7((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
|
---|
935 | #endif
|
---|
936 |
|
---|
937 | /** @def Log8Func
|
---|
938 | * Level 8 logging inside C/C++ functions.
|
---|
939 | *
|
---|
940 | * Prepends the given log message with the function name followed by a
|
---|
941 | * semicolon and space.
|
---|
942 | *
|
---|
943 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
944 | */
|
---|
945 | #ifdef LOG_USE_C99
|
---|
946 | # define Log8Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
947 | #else
|
---|
948 | # define Log8Func(a) do { Log8((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
|
---|
949 | #endif
|
---|
950 |
|
---|
951 | /** @def Log9Func
|
---|
952 | * Level 9 logging inside C/C++ functions.
|
---|
953 | *
|
---|
954 | * Prepends the given log message with the function name followed by a
|
---|
955 | * semicolon and space.
|
---|
956 | *
|
---|
957 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
958 | */
|
---|
959 | #ifdef LOG_USE_C99
|
---|
960 | # define Log9Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
961 | #else
|
---|
962 | # define Log9Func(a) do { Log9((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
|
---|
963 | #endif
|
---|
964 |
|
---|
965 | /** @def Log10Func
|
---|
966 | * Level 10 logging inside C/C++ functions.
|
---|
967 | *
|
---|
968 | * Prepends the given log message with the function name followed by a
|
---|
969 | * semicolon and space.
|
---|
970 | *
|
---|
971 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
972 | */
|
---|
973 | #ifdef LOG_USE_C99
|
---|
974 | # define Log10Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
975 | #else
|
---|
976 | # define Log10Func(a) do { Log10((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
|
---|
977 | #endif
|
---|
978 |
|
---|
979 | /** @def Log11Func
|
---|
980 | * Level 11 logging inside C/C++ functions.
|
---|
981 | *
|
---|
982 | * Prepends the given log message with the function name followed by a
|
---|
983 | * semicolon and space.
|
---|
984 | *
|
---|
985 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
986 | */
|
---|
987 | #ifdef LOG_USE_C99
|
---|
988 | # define Log11Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
989 | #else
|
---|
990 | # define Log11Func(a) do { Log11((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
|
---|
991 | #endif
|
---|
992 |
|
---|
993 | /** @def Log12Func
|
---|
994 | * Level 12 logging inside C/C++ functions.
|
---|
995 | *
|
---|
996 | * Prepends the given log message with the function name followed by a
|
---|
997 | * semicolon and space.
|
---|
998 | *
|
---|
999 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1000 | */
|
---|
1001 | #ifdef LOG_USE_C99
|
---|
1002 | # define Log12Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1003 | #else
|
---|
1004 | # define Log12Func(a) do { Log12((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
|
---|
1005 | #endif
|
---|
1006 |
|
---|
1007 | /** @def LogFlowFunc
|
---|
1008 | * Macro to log the execution flow inside C/C++ functions.
|
---|
1009 | *
|
---|
1010 | * Prepends the given log message with the function name followed by
|
---|
1011 | * a semicolon and space.
|
---|
1012 | *
|
---|
1013 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1014 | */
|
---|
1015 | #ifdef LOG_USE_C99
|
---|
1016 | # define LogFlowFunc(a) \
|
---|
1017 | _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1018 | #else
|
---|
1019 | # define LogFlowFunc(a) \
|
---|
1020 | do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
1021 | #endif
|
---|
1022 |
|
---|
1023 | /** @def LogWarnFunc
|
---|
1024 | * Macro to log a warning inside C/C++ functions.
|
---|
1025 | *
|
---|
1026 | * Prepends the given log message with the function name followed by
|
---|
1027 | * a semicolon and space.
|
---|
1028 | *
|
---|
1029 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1030 | */
|
---|
1031 | #ifdef LOG_USE_C99
|
---|
1032 | # define LogWarnFunc(a) \
|
---|
1033 | _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1034 | #else
|
---|
1035 | # define LogWarnFunc(a) \
|
---|
1036 | do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
1037 | #endif
|
---|
1038 | /** @} */
|
---|
1039 |
|
---|
1040 |
|
---|
1041 | /** @name Logging macros prefixing the this pointer value and method name.
|
---|
1042 | * @{ */
|
---|
1043 |
|
---|
1044 | /** @def LogThisFunc
|
---|
1045 | * Level 1 logging inside a C++ non-static method, with object pointer and
|
---|
1046 | * method name prefixed to the given message.
|
---|
1047 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1048 | */
|
---|
1049 | #ifdef LOG_USE_C99
|
---|
1050 | # define LogThisFunc(a) \
|
---|
1051 | _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1052 | #else
|
---|
1053 | # define LogThisFunc(a) do { Log(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
1054 | #endif
|
---|
1055 |
|
---|
1056 | /** @def Log2ThisFunc
|
---|
1057 | * Level 2 logging inside a C++ non-static method, with object pointer and
|
---|
1058 | * method name prefixed to the given message.
|
---|
1059 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1060 | */
|
---|
1061 | #ifdef LOG_USE_C99
|
---|
1062 | # define Log2ThisFunc(a) \
|
---|
1063 | _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1064 | #else
|
---|
1065 | # define Log2ThisFunc(a) do { Log2(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
|
---|
1066 | #endif
|
---|
1067 |
|
---|
1068 | /** @def Log3ThisFunc
|
---|
1069 | * Level 3 logging inside a C++ non-static method, with object pointer and
|
---|
1070 | * method name prefixed to the given message.
|
---|
1071 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1072 | */
|
---|
1073 | #ifdef LOG_USE_C99
|
---|
1074 | # define Log3ThisFunc(a) \
|
---|
1075 | _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1076 | #else
|
---|
1077 | # define Log3ThisFunc(a) do { Log3(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
|
---|
1078 | #endif
|
---|
1079 |
|
---|
1080 | /** @def Log4ThisFunc
|
---|
1081 | * Level 4 logging inside a C++ non-static method, with object pointer and
|
---|
1082 | * method name prefixed to the given message.
|
---|
1083 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1084 | */
|
---|
1085 | #ifdef LOG_USE_C99
|
---|
1086 | # define Log4ThisFunc(a) \
|
---|
1087 | _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1088 | #else
|
---|
1089 | # define Log4ThisFunc(a) do { Log4(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
|
---|
1090 | #endif
|
---|
1091 |
|
---|
1092 | /** @def Log5ThisFunc
|
---|
1093 | * Level 5 logging inside a C++ non-static method, with object pointer and
|
---|
1094 | * method name prefixed to the given message.
|
---|
1095 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1096 | */
|
---|
1097 | #ifdef LOG_USE_C99
|
---|
1098 | # define Log5ThisFunc(a) \
|
---|
1099 | _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1100 | #else
|
---|
1101 | # define Log5ThisFunc(a) do { Log5(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
|
---|
1102 | #endif
|
---|
1103 |
|
---|
1104 | /** @def Log6ThisFunc
|
---|
1105 | * Level 6 logging inside a C++ non-static method, with object pointer and
|
---|
1106 | * method name prefixed to the given message.
|
---|
1107 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1108 | */
|
---|
1109 | #ifdef LOG_USE_C99
|
---|
1110 | # define Log6ThisFunc(a) \
|
---|
1111 | _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1112 | #else
|
---|
1113 | # define Log6ThisFunc(a) do { Log6(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
|
---|
1114 | #endif
|
---|
1115 |
|
---|
1116 | /** @def Log7ThisFunc
|
---|
1117 | * Level 7 logging inside a C++ non-static method, with object pointer and
|
---|
1118 | * method name prefixed to the given message.
|
---|
1119 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1120 | */
|
---|
1121 | #ifdef LOG_USE_C99
|
---|
1122 | # define Log7ThisFunc(a) \
|
---|
1123 | _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1124 | #else
|
---|
1125 | # define Log7ThisFunc(a) do { Log7(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
|
---|
1126 | #endif
|
---|
1127 |
|
---|
1128 | /** @def Log8ThisFunc
|
---|
1129 | * Level 8 logging inside a C++ non-static method, with object pointer and
|
---|
1130 | * method name prefixed to the given message.
|
---|
1131 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1132 | */
|
---|
1133 | #ifdef LOG_USE_C99
|
---|
1134 | # define Log8ThisFunc(a) \
|
---|
1135 | _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1136 | #else
|
---|
1137 | # define Log8ThisFunc(a) do { Log8(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
|
---|
1138 | #endif
|
---|
1139 |
|
---|
1140 | /** @def Log9ThisFunc
|
---|
1141 | * Level 9 logging inside a C++ non-static method, with object pointer and
|
---|
1142 | * method name prefixed to the given message.
|
---|
1143 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1144 | */
|
---|
1145 | #ifdef LOG_USE_C99
|
---|
1146 | # define Log9ThisFunc(a) \
|
---|
1147 | _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1148 | #else
|
---|
1149 | # define Log9ThisFunc(a) do { Log9(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
|
---|
1150 | #endif
|
---|
1151 |
|
---|
1152 | /** @def Log10ThisFunc
|
---|
1153 | * Level 10 logging inside a C++ non-static method, with object pointer and
|
---|
1154 | * method name prefixed to the given message.
|
---|
1155 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1156 | */
|
---|
1157 | #ifdef LOG_USE_C99
|
---|
1158 | # define Log10ThisFunc(a) \
|
---|
1159 | _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1160 | #else
|
---|
1161 | # define Log10ThisFunc(a) do { Log10(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
|
---|
1162 | #endif
|
---|
1163 |
|
---|
1164 | /** @def Log11ThisFunc
|
---|
1165 | * Level 11 logging inside a C++ non-static method, with object pointer and
|
---|
1166 | * method name prefixed to the given message.
|
---|
1167 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1168 | */
|
---|
1169 | #ifdef LOG_USE_C99
|
---|
1170 | # define Log11ThisFunc(a) \
|
---|
1171 | _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1172 | #else
|
---|
1173 | # define Log11ThisFunc(a) do { Log11(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
|
---|
1174 | #endif
|
---|
1175 |
|
---|
1176 | /** @def Log12ThisFunc
|
---|
1177 | * Level 12 logging inside a C++ non-static method, with object pointer and
|
---|
1178 | * method name prefixed to the given message.
|
---|
1179 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1180 | */
|
---|
1181 | #ifdef LOG_USE_C99
|
---|
1182 | # define Log12ThisFunc(a) \
|
---|
1183 | _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1184 | #else
|
---|
1185 | # define Log12ThisFunc(a) do { Log12(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
|
---|
1186 | #endif
|
---|
1187 |
|
---|
1188 | /** @def LogFlowThisFunc
|
---|
1189 | * Flow level logging inside a C++ non-static method, with object pointer and
|
---|
1190 | * method name prefixed to the given message.
|
---|
1191 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1192 | */
|
---|
1193 | #ifdef LOG_USE_C99
|
---|
1194 | # define LogFlowThisFunc(a) \
|
---|
1195 | _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1196 | #else
|
---|
1197 | # define LogFlowThisFunc(a) do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
1198 | #endif
|
---|
1199 |
|
---|
1200 | /** @def LogWarnThisFunc
|
---|
1201 | * Warning level logging inside a C++ non-static method, with object pointer and
|
---|
1202 | * method name prefixed to the given message.
|
---|
1203 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1204 | */
|
---|
1205 | #ifdef LOG_USE_C99
|
---|
1206 | # define LogWarnThisFunc(a) \
|
---|
1207 | _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1208 | #else
|
---|
1209 | # define LogWarnThisFunc(a) do { LogWarn(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogWarn(a); } while (0)
|
---|
1210 | #endif
|
---|
1211 | /** @} */
|
---|
1212 |
|
---|
1213 |
|
---|
1214 | /** @name Misc Logging Macros
|
---|
1215 | * @{ */
|
---|
1216 |
|
---|
1217 | /** @def Log1Warning
|
---|
1218 | * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
|
---|
1219 | *
|
---|
1220 | * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
|
---|
1221 | */
|
---|
1222 | #if defined(LOG_USE_C99)
|
---|
1223 | # define Log1Warning(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a )
|
---|
1224 | #else
|
---|
1225 | # define Log1Warning(a) do { Log(("WARNING! ")); Log(a); } while (0)
|
---|
1226 | #endif
|
---|
1227 |
|
---|
1228 | /** @def Log1WarningFunc
|
---|
1229 | * The same as LogWarning(), but prepents the log message with the function name.
|
---|
1230 | *
|
---|
1231 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1232 | */
|
---|
1233 | #ifdef LOG_USE_C99
|
---|
1234 | # define Log1WarningFunc(a) \
|
---|
1235 | _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1236 | #else
|
---|
1237 | # define Log1WarningFunc(a) \
|
---|
1238 | do { Log((LOG_FN_FMT ": WARNING! ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
1239 | #endif
|
---|
1240 |
|
---|
1241 | /** @def Log1WarningThisFunc
|
---|
1242 | * The same as LogWarningFunc() but for class functions (methods): the resulting
|
---|
1243 | * log line is additionally prepended with a hex value of |this| pointer.
|
---|
1244 | *
|
---|
1245 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1246 | */
|
---|
1247 | #ifdef LOG_USE_C99
|
---|
1248 | # define Log1WarningThisFunc(a) \
|
---|
1249 | _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1250 | #else
|
---|
1251 | # define Log1WarningThisFunc(a) \
|
---|
1252 | do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
1253 | #endif
|
---|
1254 |
|
---|
1255 |
|
---|
1256 | /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
1257 | #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
|
---|
1258 |
|
---|
1259 | /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
1260 | #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
|
---|
1261 |
|
---|
1262 | /** Shortcut to |LogFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
|
---|
1263 | #define LogFlowFuncLeaveRC(rc) LogFlowFunc(("LEAVE: %Rrc\n", (rc)))
|
---|
1264 |
|
---|
1265 | /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
1266 | #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
|
---|
1267 |
|
---|
1268 | /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
1269 | #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
|
---|
1270 |
|
---|
1271 |
|
---|
1272 | /** @def LogObjRefCnt
|
---|
1273 | * Helper macro to print the current reference count of the given COM object
|
---|
1274 | * to the log file.
|
---|
1275 | *
|
---|
1276 | * @param pObj Pointer to the object in question (must be a pointer to an
|
---|
1277 | * IUnknown subclass or simply define COM-style AddRef() and
|
---|
1278 | * Release() methods)
|
---|
1279 | */
|
---|
1280 | #define LogObjRefCnt(pObj) \
|
---|
1281 | do { \
|
---|
1282 | if (LogIsFlowEnabled()) \
|
---|
1283 | { \
|
---|
1284 | int cRefsForLog = (pObj)->AddRef(); \
|
---|
1285 | LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), cRefsForLog - 1)); \
|
---|
1286 | (pObj)->Release(); \
|
---|
1287 | } \
|
---|
1288 | } while (0)
|
---|
1289 | /** @} */
|
---|
1290 |
|
---|
1291 |
|
---|
1292 |
|
---|
1293 | /** @name Passing Function Call Position When Logging.
|
---|
1294 | *
|
---|
1295 | * This is a little bit ugly as we have to omit the comma before the
|
---|
1296 | * position parameters so that we don't inccur any overhead in non-logging
|
---|
1297 | * builds (!defined(LOG_ENABLED).
|
---|
1298 | *
|
---|
1299 | * @{ */
|
---|
1300 | /** Source position for passing to a function call. */
|
---|
1301 | #ifdef LOG_ENABLED
|
---|
1302 | # define RTLOG_COMMA_SRC_POS , __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
|
---|
1303 | #else
|
---|
1304 | # define RTLOG_COMMA_SRC_POS RT_NOTHING
|
---|
1305 | #endif
|
---|
1306 | /** Source position declaration. */
|
---|
1307 | #ifdef LOG_ENABLED
|
---|
1308 | # define RTLOG_COMMA_SRC_POS_DECL , const char *pszFile, unsigned iLine, const char *pszFunction
|
---|
1309 | #else
|
---|
1310 | # define RTLOG_COMMA_SRC_POS_DECL RT_NOTHING
|
---|
1311 | #endif
|
---|
1312 | /** Source position arguments. */
|
---|
1313 | #ifdef LOG_ENABLED
|
---|
1314 | # define RTLOG_COMMA_SRC_POS_ARGS , pszFile, iLine, pszFunction
|
---|
1315 | #else
|
---|
1316 | # define RTLOG_COMMA_SRC_POS_ARGS RT_NOTHING
|
---|
1317 | #endif
|
---|
1318 | /** Applies NOREF() to the source position arguments. */
|
---|
1319 | #ifdef LOG_ENABLED
|
---|
1320 | # define RTLOG_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
|
---|
1321 | #else
|
---|
1322 | # define RTLOG_SRC_POS_NOREF() do { } while (0)
|
---|
1323 | #endif
|
---|
1324 | /** @} */
|
---|
1325 |
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | /** @defgroup grp_rt_log_rel Release Logging
|
---|
1329 | * @{
|
---|
1330 | */
|
---|
1331 |
|
---|
1332 | #ifdef DOXYGEN_RUNNING
|
---|
1333 | # define RTLOG_REL_DISABLED
|
---|
1334 | # define RTLOG_REL_ENABLED
|
---|
1335 | #endif
|
---|
1336 |
|
---|
1337 | /** @def RTLOG_REL_DISABLED
|
---|
1338 | * Use this compile time define to disable all release logging
|
---|
1339 | * macros.
|
---|
1340 | */
|
---|
1341 |
|
---|
1342 | /** @def RTLOG_REL_ENABLED
|
---|
1343 | * Use this compile time define to override RTLOG_REL_DISABLE.
|
---|
1344 | */
|
---|
1345 |
|
---|
1346 | /*
|
---|
1347 | * Determine whether release logging is enabled and forcefully normalize the indicators.
|
---|
1348 | */
|
---|
1349 | #if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED)
|
---|
1350 | # undef RTLOG_REL_DISABLED
|
---|
1351 | # undef RTLOG_REL_ENABLED
|
---|
1352 | # define RTLOG_REL_ENABLED
|
---|
1353 | #else
|
---|
1354 | # undef RTLOG_REL_ENABLED
|
---|
1355 | # undef RTLOG_REL_DISABLED
|
---|
1356 | # define RTLOG_REL_DISABLED
|
---|
1357 | #endif
|
---|
1358 |
|
---|
1359 | /** @name Macros for checking whether a release log level is enabled.
|
---|
1360 | * @{ */
|
---|
1361 | /** @def LogRelIsItEnabled
|
---|
1362 | * Checks whether the specified release logging group is enabled or not.
|
---|
1363 | */
|
---|
1364 | #define LogRelIsItEnabled(a_fFlags, a_iGroup) ( RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
|
---|
1365 |
|
---|
1366 | /** @def LogRelIsEnabled
|
---|
1367 | * Checks whether level 1 release logging is enabled.
|
---|
1368 | */
|
---|
1369 | #define LogRelIsEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
1370 |
|
---|
1371 | /** @def LogRelIs2Enabled
|
---|
1372 | * Checks whether level 2 release logging is enabled.
|
---|
1373 | */
|
---|
1374 | #define LogRelIs2Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
1375 |
|
---|
1376 | /** @def LogRelIs3Enabled
|
---|
1377 | * Checks whether level 3 release logging is enabled.
|
---|
1378 | */
|
---|
1379 | #define LogRelIs3Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
1380 |
|
---|
1381 | /** @def LogRelIs4Enabled
|
---|
1382 | * Checks whether level 4 release logging is enabled.
|
---|
1383 | */
|
---|
1384 | #define LogRelIs4Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
1385 |
|
---|
1386 | /** @def LogRelIs5Enabled
|
---|
1387 | * Checks whether level 5 release logging is enabled.
|
---|
1388 | */
|
---|
1389 | #define LogRelIs5Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
1390 |
|
---|
1391 | /** @def LogRelIs6Enabled
|
---|
1392 | * Checks whether level 6 release logging is enabled.
|
---|
1393 | */
|
---|
1394 | #define LogRelIs6Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
1395 |
|
---|
1396 | /** @def LogRelIs7Enabled
|
---|
1397 | * Checks whether level 7 release logging is enabled.
|
---|
1398 | */
|
---|
1399 | #define LogRelIs7Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
|
---|
1400 |
|
---|
1401 | /** @def LogRelIs8Enabled
|
---|
1402 | * Checks whether level 8 release logging is enabled.
|
---|
1403 | */
|
---|
1404 | #define LogRelIs8Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
|
---|
1405 |
|
---|
1406 | /** @def LogRelIs2Enabled
|
---|
1407 | * Checks whether level 9 release logging is enabled.
|
---|
1408 | */
|
---|
1409 | #define LogRelIs9Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
|
---|
1410 |
|
---|
1411 | /** @def LogRelIs10Enabled
|
---|
1412 | * Checks whether level 10 release logging is enabled.
|
---|
1413 | */
|
---|
1414 | #define LogRelIs10Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
|
---|
1415 |
|
---|
1416 | /** @def LogRelIs11Enabled
|
---|
1417 | * Checks whether level 10 release logging is enabled.
|
---|
1418 | */
|
---|
1419 | #define LogRelIs11Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
|
---|
1420 |
|
---|
1421 | /** @def LogRelIs12Enabled
|
---|
1422 | * Checks whether level 12 release logging is enabled.
|
---|
1423 | */
|
---|
1424 | #define LogRelIs12Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
|
---|
1425 |
|
---|
1426 | /** @def LogRelIsFlowEnabled
|
---|
1427 | * Checks whether execution flow release logging is enabled.
|
---|
1428 | */
|
---|
1429 | #define LogRelIsFlowEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
1430 |
|
---|
1431 | /** @def LogRelIsWarnEnabled
|
---|
1432 | * Checks whether warning level release logging is enabled.
|
---|
1433 | */
|
---|
1434 | #define LogRelIsWarnEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
1435 | /** @} */
|
---|
1436 |
|
---|
1437 |
|
---|
1438 | /** @def LogRelIt
|
---|
1439 | * Write to specific logger if group enabled.
|
---|
1440 | */
|
---|
1441 | /** @def LogRelItLikely
|
---|
1442 | * Write to specific logger if group enabled, assuming it likely it is enabled.
|
---|
1443 | */
|
---|
1444 | /** @def LogRelMaxIt
|
---|
1445 | * Write to specific logger if group enabled and at less than a_cMax messages
|
---|
1446 | * have hit the log. Uses a static variable to count.
|
---|
1447 | */
|
---|
1448 | #ifdef RTLOG_REL_ENABLED
|
---|
1449 | # if defined(LOG_USE_C99)
|
---|
1450 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
1451 | # define _LogRelIt(a_fFlags, a_iGroup, ...) \
|
---|
1452 | do \
|
---|
1453 | { \
|
---|
1454 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1455 | if (RT_LIKELY(!LogRelIt_pLogger)) \
|
---|
1456 | { /* likely */ } \
|
---|
1457 | else \
|
---|
1458 | RTLogLoggerExWeak(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1459 | _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1460 | } while (0)
|
---|
1461 | # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
|
---|
1462 | _LogRelIt(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
|
---|
1463 | # define _LogRelItLikely(a_fFlags, a_iGroup, ...) \
|
---|
1464 | do \
|
---|
1465 | { \
|
---|
1466 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1467 | if (LogRelIt_pLogger) \
|
---|
1468 | RTLogLoggerExWeak(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1469 | _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1470 | } while (0)
|
---|
1471 | # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
|
---|
1472 | _LogRelItLikely(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
|
---|
1473 | # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) \
|
---|
1474 | do \
|
---|
1475 | { \
|
---|
1476 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1477 | if (LogRelIt_pLogger) \
|
---|
1478 | { \
|
---|
1479 | static uint32_t s_LogRelMaxIt_cLogged = 0; \
|
---|
1480 | if (s_LogRelMaxIt_cLogged < (a_cMax)) \
|
---|
1481 | { \
|
---|
1482 | s_LogRelMaxIt_cLogged++; \
|
---|
1483 | RTLogLoggerExWeak(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1484 | } \
|
---|
1485 | } \
|
---|
1486 | _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1487 | } while (0)
|
---|
1488 | # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
|
---|
1489 | _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
|
---|
1490 | # else
|
---|
1491 | # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
|
---|
1492 | do \
|
---|
1493 | { \
|
---|
1494 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1495 | if (LogRelIt_pLogger) \
|
---|
1496 | { \
|
---|
1497 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
1498 | } \
|
---|
1499 | LogIt(a_fFlags, a_iGroup, fmtargs); \
|
---|
1500 | } while (0)
|
---|
1501 | # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
|
---|
1502 | do \
|
---|
1503 | { \
|
---|
1504 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1505 | if (RT_LIKELY(!LogRelIt_pLogger)) \
|
---|
1506 | { /* likely */ } \
|
---|
1507 | else \
|
---|
1508 | { \
|
---|
1509 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
1510 | } \
|
---|
1511 | LogIt(a_fFlags, a_iGroup, fmtargs); \
|
---|
1512 | } while (0)
|
---|
1513 | # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
|
---|
1514 | do \
|
---|
1515 | { \
|
---|
1516 | PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceExWeak(RT_MAKE_U32(a_fFlags, a_iGroup)); \
|
---|
1517 | if (LogRelIt_pLogger) \
|
---|
1518 | { \
|
---|
1519 | static uint32_t s_LogRelMaxIt_cLogged = 0; \
|
---|
1520 | if (s_LogRelMaxIt_cLogged < (a_cMax)) \
|
---|
1521 | { \
|
---|
1522 | s_LogRelMaxIt_cLogged++; \
|
---|
1523 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
1524 | } \
|
---|
1525 | } \
|
---|
1526 | LogIt(a_fFlags, a_iGroup, fmtargs); \
|
---|
1527 | } while (0)
|
---|
1528 | # endif
|
---|
1529 | #else /* !RTLOG_REL_ENABLED */
|
---|
1530 | # define LogRelIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
1531 | # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
1532 | # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
1533 | # if defined(LOG_USE_C99)
|
---|
1534 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
1535 | # define _LogRelIt(a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
1536 | # define _LogRelItLikely(a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
1537 | # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
1538 | # endif
|
---|
1539 | #endif /* !RTLOG_REL_ENABLED */
|
---|
1540 |
|
---|
1541 |
|
---|
1542 | /** @name Basic release logging macros
|
---|
1543 | * @{ */
|
---|
1544 | /** @def LogRel
|
---|
1545 | * Level 1 release logging.
|
---|
1546 | */
|
---|
1547 | #define LogRel(a) LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
1548 |
|
---|
1549 | /** @def LogRel2
|
---|
1550 | * Level 2 release logging.
|
---|
1551 | */
|
---|
1552 | #define LogRel2(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
1553 |
|
---|
1554 | /** @def LogRel3
|
---|
1555 | * Level 3 release logging.
|
---|
1556 | */
|
---|
1557 | #define LogRel3(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
1558 |
|
---|
1559 | /** @def LogRel4
|
---|
1560 | * Level 4 release logging.
|
---|
1561 | */
|
---|
1562 | #define LogRel4(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
1563 |
|
---|
1564 | /** @def LogRel5
|
---|
1565 | * Level 5 release logging.
|
---|
1566 | */
|
---|
1567 | #define LogRel5(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
1568 |
|
---|
1569 | /** @def LogRel6
|
---|
1570 | * Level 6 release logging.
|
---|
1571 | */
|
---|
1572 | #define LogRel6(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
1573 |
|
---|
1574 | /** @def LogRel7
|
---|
1575 | * Level 7 release logging.
|
---|
1576 | */
|
---|
1577 | #define LogRel7(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
|
---|
1578 |
|
---|
1579 | /** @def LogRel8
|
---|
1580 | * Level 8 release logging.
|
---|
1581 | */
|
---|
1582 | #define LogRel8(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
|
---|
1583 |
|
---|
1584 | /** @def LogRel9
|
---|
1585 | * Level 9 release logging.
|
---|
1586 | */
|
---|
1587 | #define LogRel9(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
|
---|
1588 |
|
---|
1589 | /** @def LogRel10
|
---|
1590 | * Level 10 release logging.
|
---|
1591 | */
|
---|
1592 | #define LogRel10(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
|
---|
1593 |
|
---|
1594 | /** @def LogRel11
|
---|
1595 | * Level 11 release logging.
|
---|
1596 | */
|
---|
1597 | #define LogRel11(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
|
---|
1598 |
|
---|
1599 | /** @def LogRel12
|
---|
1600 | * Level 12 release logging.
|
---|
1601 | */
|
---|
1602 | #define LogRel12(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
|
---|
1603 |
|
---|
1604 | /** @def LogRelFlow
|
---|
1605 | * Logging of execution flow.
|
---|
1606 | */
|
---|
1607 | #define LogRelFlow(a) LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
1608 |
|
---|
1609 | /** @def LogRelWarn
|
---|
1610 | * Warning level release logging.
|
---|
1611 | */
|
---|
1612 | #define LogRelWarn(a) LogRelIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
|
---|
1613 | /** @} */
|
---|
1614 |
|
---|
1615 |
|
---|
1616 |
|
---|
1617 | /** @name Basic release logging macros with local max
|
---|
1618 | * @{ */
|
---|
1619 | /** @def LogRelMax
|
---|
1620 | * Level 1 release logging with a max number of log entries.
|
---|
1621 | */
|
---|
1622 | #define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
1623 |
|
---|
1624 | /** @def LogRelMax2
|
---|
1625 | * Level 2 release logging with a max number of log entries.
|
---|
1626 | */
|
---|
1627 | #define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
1628 |
|
---|
1629 | /** @def LogRelMax3
|
---|
1630 | * Level 3 release logging with a max number of log entries.
|
---|
1631 | */
|
---|
1632 | #define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
1633 |
|
---|
1634 | /** @def LogRelMax4
|
---|
1635 | * Level 4 release logging with a max number of log entries.
|
---|
1636 | */
|
---|
1637 | #define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
1638 |
|
---|
1639 | /** @def LogRelMax5
|
---|
1640 | * Level 5 release logging with a max number of log entries.
|
---|
1641 | */
|
---|
1642 | #define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
1643 |
|
---|
1644 | /** @def LogRelMax6
|
---|
1645 | * Level 6 release logging with a max number of log entries.
|
---|
1646 | */
|
---|
1647 | #define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
1648 |
|
---|
1649 | /** @def LogRelMax7
|
---|
1650 | * Level 7 release logging with a max number of log entries.
|
---|
1651 | */
|
---|
1652 | #define LogRelMax7(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
|
---|
1653 |
|
---|
1654 | /** @def LogRelMax8
|
---|
1655 | * Level 8 release logging with a max number of log entries.
|
---|
1656 | */
|
---|
1657 | #define LogRelMax8(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
|
---|
1658 |
|
---|
1659 | /** @def LogRelMax9
|
---|
1660 | * Level 9 release logging with a max number of log entries.
|
---|
1661 | */
|
---|
1662 | #define LogRelMax9(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
|
---|
1663 |
|
---|
1664 | /** @def LogRelMax10
|
---|
1665 | * Level 10 release logging with a max number of log entries.
|
---|
1666 | */
|
---|
1667 | #define LogRelMax10(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
|
---|
1668 |
|
---|
1669 | /** @def LogRelMax11
|
---|
1670 | * Level 11 release logging with a max number of log entries.
|
---|
1671 | */
|
---|
1672 | #define LogRelMax11(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
|
---|
1673 |
|
---|
1674 | /** @def LogRelMax12
|
---|
1675 | * Level 12 release logging with a max number of log entries.
|
---|
1676 | */
|
---|
1677 | #define LogRelMax12(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
|
---|
1678 |
|
---|
1679 | /** @def LogRelMaxFlow
|
---|
1680 | * Logging of execution flow with a max number of log entries.
|
---|
1681 | */
|
---|
1682 | #define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
1683 | /** @} */
|
---|
1684 |
|
---|
1685 |
|
---|
1686 | /** @name Release logging macros prefixing the current function name.
|
---|
1687 | * @{ */
|
---|
1688 |
|
---|
1689 | /** @def LogRelFunc
|
---|
1690 | * Release logging. Prepends the given log message with the function name
|
---|
1691 | * followed by a semicolon and space.
|
---|
1692 | */
|
---|
1693 | #ifdef LOG_USE_C99
|
---|
1694 | # define LogRelFunc(a) \
|
---|
1695 | _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1696 | #else
|
---|
1697 | # define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
1698 | #endif
|
---|
1699 |
|
---|
1700 | /** @def LogRelFlowFunc
|
---|
1701 | * Release logging. Macro to log the execution flow inside C/C++ functions.
|
---|
1702 | *
|
---|
1703 | * Prepends the given log message with the function name followed by
|
---|
1704 | * a semicolon and space.
|
---|
1705 | *
|
---|
1706 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1707 | */
|
---|
1708 | #ifdef LOG_USE_C99
|
---|
1709 | # define LogRelFlowFunc(a) _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1710 | #else
|
---|
1711 | # define LogRelFlowFunc(a) do { LogRelFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
|
---|
1712 | #endif
|
---|
1713 |
|
---|
1714 | /** @def LogRelMaxFunc
|
---|
1715 | * Release logging. Prepends the given log message with the function name
|
---|
1716 | * followed by a semicolon and space.
|
---|
1717 | */
|
---|
1718 | #ifdef LOG_USE_C99
|
---|
1719 | # define LogRelMaxFunc(a_cMax, a) \
|
---|
1720 | _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1721 | #else
|
---|
1722 | # define LogRelMaxFunc(a_cMax, a) \
|
---|
1723 | do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
|
---|
1724 | #endif
|
---|
1725 |
|
---|
1726 | /** @def LogRelMaxFlowFunc
|
---|
1727 | * Release logging. Macro to log the execution flow inside C/C++ functions.
|
---|
1728 | *
|
---|
1729 | * Prepends the given log message with the function name followed by
|
---|
1730 | * a semicolon and space.
|
---|
1731 | *
|
---|
1732 | * @param a_cMax Max number of times this should hit the log.
|
---|
1733 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1734 | */
|
---|
1735 | #ifdef LOG_USE_C99
|
---|
1736 | # define LogRelMaxFlowFunc(a_cMax, a) \
|
---|
1737 | _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1738 | #else
|
---|
1739 | # define LogRelMaxFlowFunc(a_cMax, a) \
|
---|
1740 | do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0)
|
---|
1741 | #endif
|
---|
1742 |
|
---|
1743 | /** @} */
|
---|
1744 |
|
---|
1745 |
|
---|
1746 | /** @name Release Logging macros prefixing the this pointer value and method name.
|
---|
1747 | * @{ */
|
---|
1748 |
|
---|
1749 | /** @def LogRelThisFunc
|
---|
1750 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
1751 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
1752 | */
|
---|
1753 | #ifdef LOG_USE_C99
|
---|
1754 | # define LogRelThisFunc(a) \
|
---|
1755 | _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1756 | #else
|
---|
1757 | # define LogRelThisFunc(a) \
|
---|
1758 | do { LogRel(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
1759 | #endif
|
---|
1760 |
|
---|
1761 | /** @def LogRelMaxThisFunc
|
---|
1762 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
1763 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
1764 | * @param a_cMax Max number of times this should hit the log.
|
---|
1765 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1766 | */
|
---|
1767 | #ifdef LOG_USE_C99
|
---|
1768 | # define LogRelMaxThisFunc(a_cMax, a) \
|
---|
1769 | _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1770 | #else
|
---|
1771 | # define LogRelMaxThisFunc(a_cMax, a) \
|
---|
1772 | do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
|
---|
1773 | #endif
|
---|
1774 |
|
---|
1775 | /** @def LogRelFlowThisFunc
|
---|
1776 | * The same as LogRelFlowFunc but for class functions (methods): the resulting
|
---|
1777 | * log line is additionally prepended with a hex value of |this| pointer.
|
---|
1778 | */
|
---|
1779 | #ifdef LOG_USE_C99
|
---|
1780 | # define LogRelFlowThisFunc(a) \
|
---|
1781 | _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1782 | #else
|
---|
1783 | # define LogRelFlowThisFunc(a) do { LogRelFlow(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
|
---|
1784 | #endif
|
---|
1785 |
|
---|
1786 |
|
---|
1787 | /** Shortcut to |LogRelFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
1788 | #define LogRelFlowFuncEnter() LogRelFlowFunc(("ENTER\n"))
|
---|
1789 |
|
---|
1790 | /** Shortcut to |LogRelFlowFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
1791 | #define LogRelFlowFuncLeave() LogRelFlowFunc(("LEAVE\n"))
|
---|
1792 |
|
---|
1793 | /** Shortcut to |LogRelFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
|
---|
1794 | #define LogRelFlowFuncLeaveRC(rc) LogRelFlowFunc(("LEAVE: %Rrc\n", (rc)))
|
---|
1795 |
|
---|
1796 | /** Shortcut to |LogRelFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
1797 | #define LogRelFlowThisFuncEnter() LogRelFlowThisFunc(("ENTER\n"))
|
---|
1798 |
|
---|
1799 | /** Shortcut to |LogRelFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
1800 | #define LogRelFlowThisFuncLeave() LogRelFlowThisFunc(("LEAVE\n"))
|
---|
1801 |
|
---|
1802 | /** @} */
|
---|
1803 |
|
---|
1804 |
|
---|
1805 | /**
|
---|
1806 | * Sets the default release logger instance.
|
---|
1807 | *
|
---|
1808 | * @returns The old default instance.
|
---|
1809 | * @param pLogger The new default release logger instance.
|
---|
1810 | */
|
---|
1811 | RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger);
|
---|
1812 |
|
---|
1813 | /**
|
---|
1814 | * Gets the default release logger instance.
|
---|
1815 | *
|
---|
1816 | * @returns Pointer to default release logger instance if availble, otherwise NULL.
|
---|
1817 | */
|
---|
1818 | RTDECL(PRTLOGGER) RTLogRelGetDefaultInstance(void);
|
---|
1819 |
|
---|
1820 | /** @copydoc RTLogRelGetDefaultInstance */
|
---|
1821 | typedef DECLCALLBACKTYPE(PRTLOGGER, FNLOGRELGETDEFAULTINSTANCE,(void));
|
---|
1822 | /** Pointer to RTLogRelGetDefaultInstance. */
|
---|
1823 | typedef FNLOGRELGETDEFAULTINSTANCE *PFNLOGRELGETDEFAULTINSTANCE;
|
---|
1824 |
|
---|
1825 | /** "Weak symbol" emulation for RTLogRelGetDefaultInstance.
|
---|
1826 | * @note This is first set when RTLogRelSetDefaultInstance is called. */
|
---|
1827 | extern RTDATADECL(PFNLOGRELGETDEFAULTINSTANCE) g_pfnRTLogRelGetDefaultInstance;
|
---|
1828 |
|
---|
1829 | /** "Weak symbol" wrapper for RTLogRelGetDefaultInstance. */
|
---|
1830 | DECL_FORCE_INLINE(PRTLOGGER) RTLogRelGetDefaultInstanceWeak(void)
|
---|
1831 | {
|
---|
1832 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
1833 | if (g_pfnRTLogRelGetDefaultInstance)
|
---|
1834 | return g_pfnRTLogRelGetDefaultInstance();
|
---|
1835 | return NULL;
|
---|
1836 | #else
|
---|
1837 | return RTLogRelGetDefaultInstance();
|
---|
1838 | #endif
|
---|
1839 | }
|
---|
1840 |
|
---|
1841 | /**
|
---|
1842 | * Gets the default release logger instance.
|
---|
1843 | *
|
---|
1844 | * @returns Pointer to default release logger instance if availble, otherwise NULL.
|
---|
1845 | * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
|
---|
1846 | * the high 16 bits.
|
---|
1847 | */
|
---|
1848 | RTDECL(PRTLOGGER) RTLogRelGetDefaultInstanceEx(uint32_t fFlagsAndGroup);
|
---|
1849 |
|
---|
1850 | /** @copydoc RTLogRelGetDefaultInstanceEx */
|
---|
1851 | typedef DECLCALLBACKTYPE(PRTLOGGER, FNLOGRELGETDEFAULTINSTANCEEX,(uint32_t fFlagsAndGroup));
|
---|
1852 | /** Pointer to RTLogRelGetDefaultInstanceEx. */
|
---|
1853 | typedef FNLOGRELGETDEFAULTINSTANCEEX *PFNLOGRELGETDEFAULTINSTANCEEX;
|
---|
1854 |
|
---|
1855 | /** "Weak symbol" emulation for RTLogRelGetDefaultInstanceEx.
|
---|
1856 | * @note This is first set when RTLogRelSetDefaultInstance is called. */
|
---|
1857 | extern RTDATADECL(PFNLOGRELGETDEFAULTINSTANCEEX) g_pfnRTLogRelGetDefaultInstanceEx;
|
---|
1858 |
|
---|
1859 | /** "Weak symbol" wrapper for RTLogRelGetDefaultInstanceEx. */
|
---|
1860 | DECL_FORCE_INLINE(PRTLOGGER) RTLogRelGetDefaultInstanceExWeak(uint32_t fFlagsAndGroup)
|
---|
1861 | {
|
---|
1862 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
1863 | if (g_pfnRTLogRelGetDefaultInstanceEx)
|
---|
1864 | return g_pfnRTLogRelGetDefaultInstanceEx(fFlagsAndGroup);
|
---|
1865 | return NULL;
|
---|
1866 | #else
|
---|
1867 | return RTLogRelGetDefaultInstanceEx(fFlagsAndGroup);
|
---|
1868 | #endif
|
---|
1869 | }
|
---|
1870 |
|
---|
1871 |
|
---|
1872 | /**
|
---|
1873 | * Write to a logger instance, defaulting to the release one.
|
---|
1874 | *
|
---|
1875 | * This function will check whether the instance, group and flags makes up a
|
---|
1876 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1877 | *
|
---|
1878 | * @param pLogger Pointer to logger instance.
|
---|
1879 | * @param fFlags The logging flags.
|
---|
1880 | * @param iGroup The group.
|
---|
1881 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1882 | * only for internal usage!
|
---|
1883 | * @param pszFormat Format string.
|
---|
1884 | * @param ... Format arguments.
|
---|
1885 | * @remark This is a worker function for LogRelIt.
|
---|
1886 | */
|
---|
1887 | RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
1888 | const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
|
---|
1889 |
|
---|
1890 | /**
|
---|
1891 | * Write to a logger instance, defaulting to the release one.
|
---|
1892 | *
|
---|
1893 | * This function will check whether the instance, group and flags makes up a
|
---|
1894 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1895 | *
|
---|
1896 | * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
|
---|
1897 | * @param fFlags The logging flags.
|
---|
1898 | * @param iGroup The group.
|
---|
1899 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1900 | * only for internal usage!
|
---|
1901 | * @param pszFormat Format string.
|
---|
1902 | * @param args Format arguments.
|
---|
1903 | */
|
---|
1904 | RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
1905 | const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
|
---|
1906 |
|
---|
1907 | /**
|
---|
1908 | * printf like function for writing to the default release log.
|
---|
1909 | *
|
---|
1910 | * @param pszFormat Printf like format string.
|
---|
1911 | * @param ... Optional arguments as specified in pszFormat.
|
---|
1912 | *
|
---|
1913 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1914 | */
|
---|
1915 | RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
1916 |
|
---|
1917 | /**
|
---|
1918 | * vprintf like function for writing to the default release log.
|
---|
1919 | *
|
---|
1920 | * @param pszFormat Printf like format string.
|
---|
1921 | * @param args Optional arguments as specified in pszFormat.
|
---|
1922 | *
|
---|
1923 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1924 | */
|
---|
1925 | RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
1926 |
|
---|
1927 | /**
|
---|
1928 | * Changes the buffering setting of the default release logger.
|
---|
1929 | *
|
---|
1930 | * This can be used for optimizing longish logging sequences.
|
---|
1931 | *
|
---|
1932 | * @returns The old state.
|
---|
1933 | * @param fBuffered The new state.
|
---|
1934 | */
|
---|
1935 | RTDECL(bool) RTLogRelSetBuffering(bool fBuffered);
|
---|
1936 |
|
---|
1937 | /** @} */
|
---|
1938 |
|
---|
1939 |
|
---|
1940 |
|
---|
1941 | /** @name COM port logging
|
---|
1942 | * @{
|
---|
1943 | */
|
---|
1944 |
|
---|
1945 | #ifdef DOXYGEN_RUNNING
|
---|
1946 | # define LOG_TO_COM
|
---|
1947 | # define LOG_NO_COM
|
---|
1948 | #endif
|
---|
1949 |
|
---|
1950 | /** @def LOG_TO_COM
|
---|
1951 | * Redirects the normal logging macros to the serial versions.
|
---|
1952 | */
|
---|
1953 |
|
---|
1954 | /** @def LOG_NO_COM
|
---|
1955 | * Disables all LogCom* macros.
|
---|
1956 | */
|
---|
1957 |
|
---|
1958 | /** @def LogCom
|
---|
1959 | * Generic logging to serial port.
|
---|
1960 | */
|
---|
1961 | #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
|
---|
1962 | # define LogCom(a) RTLogComPrintf a
|
---|
1963 | #else
|
---|
1964 | # define LogCom(a) do { } while (0)
|
---|
1965 | #endif
|
---|
1966 |
|
---|
1967 | /** @def LogComFlow
|
---|
1968 | * Logging to serial port of execution flow.
|
---|
1969 | */
|
---|
1970 | #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
|
---|
1971 | # define LogComFlow(a) RTLogComPrintf a
|
---|
1972 | #else
|
---|
1973 | # define LogComFlow(a) do { } while (0)
|
---|
1974 | #endif
|
---|
1975 |
|
---|
1976 | #ifdef LOG_TO_COM
|
---|
1977 | # undef Log
|
---|
1978 | # define Log(a) LogCom(a)
|
---|
1979 | # undef LogFlow
|
---|
1980 | # define LogFlow(a) LogComFlow(a)
|
---|
1981 | #endif
|
---|
1982 |
|
---|
1983 | /** @} */
|
---|
1984 |
|
---|
1985 |
|
---|
1986 | /** @name Backdoor Logging
|
---|
1987 | * @{
|
---|
1988 | */
|
---|
1989 |
|
---|
1990 | #ifdef DOXYGEN_RUNNING
|
---|
1991 | # define LOG_TO_BACKDOOR
|
---|
1992 | # define LOG_NO_BACKDOOR
|
---|
1993 | #endif
|
---|
1994 |
|
---|
1995 | /** @def LOG_TO_BACKDOOR
|
---|
1996 | * Redirects the normal logging macros to the backdoor versions.
|
---|
1997 | */
|
---|
1998 |
|
---|
1999 | /** @def LOG_NO_BACKDOOR
|
---|
2000 | * Disables all LogBackdoor* macros.
|
---|
2001 | */
|
---|
2002 |
|
---|
2003 | /** @def LogBackdoor
|
---|
2004 | * Generic logging to the VBox backdoor via port I/O.
|
---|
2005 | */
|
---|
2006 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
2007 | # define LogBackdoor(a) RTLogBackdoorPrintf a
|
---|
2008 | #else
|
---|
2009 | # define LogBackdoor(a) do { } while (0)
|
---|
2010 | #endif
|
---|
2011 |
|
---|
2012 | /** @def LogBackdoorFlow
|
---|
2013 | * Logging of execution flow messages to the backdoor I/O port.
|
---|
2014 | */
|
---|
2015 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
2016 | # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
|
---|
2017 | #else
|
---|
2018 | # define LogBackdoorFlow(a) do { } while (0)
|
---|
2019 | #endif
|
---|
2020 |
|
---|
2021 | /** @def LogRelBackdoor
|
---|
2022 | * Release logging to the VBox backdoor via port I/O.
|
---|
2023 | */
|
---|
2024 | #if !defined(LOG_NO_BACKDOOR)
|
---|
2025 | # define LogRelBackdoor(a) RTLogBackdoorPrintf a
|
---|
2026 | #else
|
---|
2027 | # define LogRelBackdoor(a) do { } while (0)
|
---|
2028 | #endif
|
---|
2029 |
|
---|
2030 | #ifdef LOG_TO_BACKDOOR
|
---|
2031 | # undef Log
|
---|
2032 | # define Log(a) LogBackdoor(a)
|
---|
2033 | # undef LogFlow
|
---|
2034 | # define LogFlow(a) LogBackdoorFlow(a)
|
---|
2035 | # undef LogRel
|
---|
2036 | # define LogRel(a) LogRelBackdoor(a)
|
---|
2037 | # if defined(LOG_USE_C99)
|
---|
2038 | # undef _LogIt
|
---|
2039 | # define _LogIt(a_fFlags, a_iGroup, ...) LogBackdoor((__VA_ARGS__))
|
---|
2040 | # endif
|
---|
2041 | #endif
|
---|
2042 |
|
---|
2043 | /** @} */
|
---|
2044 |
|
---|
2045 |
|
---|
2046 |
|
---|
2047 | /**
|
---|
2048 | * Gets the default logger instance, creating it if necessary.
|
---|
2049 | *
|
---|
2050 | * @returns Pointer to default logger instance if availble, otherwise NULL.
|
---|
2051 | */
|
---|
2052 | RTDECL(PRTLOGGER) RTLogDefaultInstance(void);
|
---|
2053 |
|
---|
2054 | /**
|
---|
2055 | * Gets the logger instance if enabled, creating it if necessary.
|
---|
2056 | *
|
---|
2057 | * @returns Pointer to default logger instance, if group has the specified
|
---|
2058 | * flags enabled. Otherwise NULL is returned.
|
---|
2059 | * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
|
---|
2060 | * the high 16 bits.
|
---|
2061 | */
|
---|
2062 | RTDECL(PRTLOGGER) RTLogDefaultInstanceEx(uint32_t fFlagsAndGroup);
|
---|
2063 |
|
---|
2064 | /**
|
---|
2065 | * Gets the default logger instance (does not create one).
|
---|
2066 | *
|
---|
2067 | * @returns Pointer to default logger instance if availble, otherwise NULL.
|
---|
2068 | */
|
---|
2069 | RTDECL(PRTLOGGER) RTLogGetDefaultInstance(void);
|
---|
2070 |
|
---|
2071 | /** @copydoc RTLogGetDefaultInstance */
|
---|
2072 | typedef DECLCALLBACKTYPE(PRTLOGGER, FNLOGGETDEFAULTINSTANCE,(void));
|
---|
2073 | /** Pointer to RTLogGetDefaultInstance. */
|
---|
2074 | typedef FNLOGGETDEFAULTINSTANCE *PFNLOGGETDEFAULTINSTANCE;
|
---|
2075 |
|
---|
2076 | /** "Weak symbol" emulation for RTLogGetDefaultInstance.
|
---|
2077 | * @note This is first set when RTLogSetDefaultInstance is called. */
|
---|
2078 | extern RTDATADECL(PFNLOGGETDEFAULTINSTANCE) g_pfnRTLogGetDefaultInstance;
|
---|
2079 |
|
---|
2080 | /** "Weak symbol" wrapper for RTLogGetDefaultInstance. */
|
---|
2081 | DECL_FORCE_INLINE(PRTLOGGER) RTLogGetDefaultInstanceWeak(void)
|
---|
2082 | {
|
---|
2083 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
2084 | if (g_pfnRTLogGetDefaultInstance)
|
---|
2085 | return g_pfnRTLogGetDefaultInstance();
|
---|
2086 | return NULL;
|
---|
2087 | #else
|
---|
2088 | return RTLogGetDefaultInstance();
|
---|
2089 | #endif
|
---|
2090 | }
|
---|
2091 |
|
---|
2092 | /**
|
---|
2093 | * Gets the default logger instance if enabled (does not create one).
|
---|
2094 | *
|
---|
2095 | * @returns Pointer to default logger instance, if group has the specified
|
---|
2096 | * flags enabled. Otherwise NULL is returned.
|
---|
2097 | * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
|
---|
2098 | * the high 16 bits.
|
---|
2099 | */
|
---|
2100 | RTDECL(PRTLOGGER) RTLogGetDefaultInstanceEx(uint32_t fFlagsAndGroup);
|
---|
2101 |
|
---|
2102 | /** @copydoc RTLogGetDefaultInstanceEx */
|
---|
2103 | typedef DECLCALLBACKTYPE(PRTLOGGER, FNLOGGETDEFAULTINSTANCEEX,(uint32_t fFlagsAndGroup));
|
---|
2104 | /** Pointer to RTLogGetDefaultInstanceEx. */
|
---|
2105 | typedef FNLOGGETDEFAULTINSTANCEEX *PFNLOGGETDEFAULTINSTANCEEX;
|
---|
2106 |
|
---|
2107 | /** "Weak symbol" emulation for RTLogGetDefaultInstanceEx.
|
---|
2108 | * @note This is first set when RTLogSetDefaultInstance is called. */
|
---|
2109 | extern RTDATADECL(PFNLOGGETDEFAULTINSTANCEEX) g_pfnRTLogGetDefaultInstanceEx;
|
---|
2110 |
|
---|
2111 | /** "Weak symbol" wrapper for RTLogGetDefaultInstanceEx. */
|
---|
2112 | DECL_FORCE_INLINE(PRTLOGGER) RTLogGetDefaultInstanceExWeak(uint32_t fFlagsAndGroup)
|
---|
2113 | {
|
---|
2114 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
2115 | if (g_pfnRTLogGetDefaultInstanceEx)
|
---|
2116 | return g_pfnRTLogGetDefaultInstanceEx(fFlagsAndGroup);
|
---|
2117 | return NULL;
|
---|
2118 | #else
|
---|
2119 | return RTLogGetDefaultInstanceEx(fFlagsAndGroup);
|
---|
2120 | #endif
|
---|
2121 | }
|
---|
2122 |
|
---|
2123 | /**
|
---|
2124 | * Sets the default logger instance.
|
---|
2125 | *
|
---|
2126 | * @returns The old default instance.
|
---|
2127 | * @param pLogger The new default logger instance.
|
---|
2128 | */
|
---|
2129 | RTDECL(PRTLOGGER) RTLogSetDefaultInstance(PRTLOGGER pLogger);
|
---|
2130 |
|
---|
2131 | #ifdef IN_RING0
|
---|
2132 | /**
|
---|
2133 | * Changes the default logger instance for the current thread.
|
---|
2134 | *
|
---|
2135 | * @returns IPRT status code.
|
---|
2136 | * @param pLogger The logger instance. Pass NULL for deregistration.
|
---|
2137 | * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
|
---|
2138 | * all instances with this key will be deregistered. So in
|
---|
2139 | * order to only deregister the instance associated with the
|
---|
2140 | * current thread use 0.
|
---|
2141 | */
|
---|
2142 | RTR0DECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
|
---|
2143 | #endif /* IN_RING0 */
|
---|
2144 |
|
---|
2145 | /**
|
---|
2146 | * Creates the default logger instance for IPRT users.
|
---|
2147 | *
|
---|
2148 | * Any user of the logging features will need to implement
|
---|
2149 | * this or use the generic dummy.
|
---|
2150 | *
|
---|
2151 | * @returns Pointer to the logger instance.
|
---|
2152 | */
|
---|
2153 | RTDECL(PRTLOGGER) RTLogDefaultInit(void);
|
---|
2154 |
|
---|
2155 | /**
|
---|
2156 | * This is the 2nd half of what RTLogGetDefaultInstanceEx() and
|
---|
2157 | * RTLogRelGetDefaultInstanceEx() does.
|
---|
2158 | *
|
---|
2159 | * @returns If the group has the specified flags enabled @a pLogger will be
|
---|
2160 | * returned returned. Otherwise NULL is returned.
|
---|
2161 | * @param pLogger The logger. NULL is NULL.
|
---|
2162 | * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
|
---|
2163 | * the high 16 bits.
|
---|
2164 | */
|
---|
2165 | RTDECL(PRTLOGGER) RTLogCheckGroupFlags(PRTLOGGER pLogger, uint32_t fFlagsAndGroup);
|
---|
2166 |
|
---|
2167 | /**
|
---|
2168 | * Create a logger instance.
|
---|
2169 | *
|
---|
2170 | * @returns iprt status code.
|
---|
2171 | *
|
---|
2172 | * @param ppLogger Where to store the logger instance.
|
---|
2173 | * @param fFlags Logger instance flags, a combination of the
|
---|
2174 | * RTLOGFLAGS_* values.
|
---|
2175 | * @param pszGroupSettings The initial group settings.
|
---|
2176 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
2177 | * this instance.
|
---|
2178 | * @param cGroups Number of groups in the array.
|
---|
2179 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
2180 | * around for the life of the logger instance.
|
---|
2181 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
2182 | * if pszFilenameFmt specified.
|
---|
2183 | * @param pszFilenameFmt Log filename format string. Standard
|
---|
2184 | * RTStrFormat().
|
---|
2185 | * @param ... Format arguments.
|
---|
2186 | */
|
---|
2187 | RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint64_t fFlags, const char *pszGroupSettings,
|
---|
2188 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
2189 | uint32_t fDestFlags, const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
|
---|
2190 |
|
---|
2191 | /**
|
---|
2192 | * Create a logger instance.
|
---|
2193 | *
|
---|
2194 | * @returns iprt status code.
|
---|
2195 | *
|
---|
2196 | * @param ppLogger Where to store the logger instance.
|
---|
2197 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
2198 | * this instance (ring-3 only).
|
---|
2199 | * @param fFlags Logger instance flags, a combination of the
|
---|
2200 | * RTLOGFLAGS_* values.
|
---|
2201 | * @param pszGroupSettings The initial group settings.
|
---|
2202 | * @param cGroups Number of groups in the array.
|
---|
2203 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
2204 | * around for the life of the logger instance.
|
---|
2205 | * @param cMaxEntriesPerGroup The max number of entries per group. UINT32_MAX
|
---|
2206 | * or zero for unlimited.
|
---|
2207 | * @param cBufDescs Number of buffer descriptors that @a paBufDescs
|
---|
2208 | * points to. Zero for defaults.
|
---|
2209 | * @param paBufDescs Buffer descriptors, optional.
|
---|
2210 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
2211 | * if pszFilenameFmt specified.
|
---|
2212 | * @param pfnPhase Callback function for starting logging and for
|
---|
2213 | * ending or starting a new file for log history
|
---|
2214 | * rotation. NULL is OK.
|
---|
2215 | * @param cHistory Number of old log files to keep when performing
|
---|
2216 | * log history rotation. 0 means no history.
|
---|
2217 | * @param cbHistoryFileMax Maximum size of log file when performing
|
---|
2218 | * history rotation. 0 means no size limit.
|
---|
2219 | * @param cSecsHistoryTimeSlot Maximum time interval per log file when
|
---|
2220 | * performing history rotation, in seconds.
|
---|
2221 | * 0 means time limit.
|
---|
2222 | * @param pOutputIf The optional file output interface, can be NULL which will
|
---|
2223 | * make use of the default one.
|
---|
2224 | * @param pvOutputIfUser The opaque user data to pass to the callbacks in the output interface.
|
---|
2225 | * @param pErrInfo Where to return extended error information.
|
---|
2226 | * Optional.
|
---|
2227 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
2228 | * @param ... Format arguments.
|
---|
2229 | */
|
---|
2230 | RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, const char *pszEnvVarBase, uint64_t fFlags, const char *pszGroupSettings,
|
---|
2231 | unsigned cGroups, const char * const *papszGroups, uint32_t cMaxEntriesPerGroup,
|
---|
2232 | uint32_t cBufDescs, PRTLOGBUFFERDESC paBufDescs, uint32_t fDestFlags,
|
---|
2233 | PFNRTLOGPHASE pfnPhase, uint32_t cHistory, uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
|
---|
2234 | PCRTLOGOUTPUTIF pOutputIf, void *pvOutputIfUser,
|
---|
2235 | PRTERRINFO pErrInfo, const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(18, 19);
|
---|
2236 |
|
---|
2237 | /**
|
---|
2238 | * Create a logger instance.
|
---|
2239 | *
|
---|
2240 | * @returns iprt status code.
|
---|
2241 | *
|
---|
2242 | * @param ppLogger Where to store the logger instance.
|
---|
2243 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
2244 | * this instance (ring-3 only).
|
---|
2245 | * @param fFlags Logger instance flags, a combination of the
|
---|
2246 | * RTLOGFLAGS_* values.
|
---|
2247 | * @param pszGroupSettings The initial group settings.
|
---|
2248 | * @param cGroups Number of groups in the array.
|
---|
2249 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
2250 | * around for the life of the logger instance.
|
---|
2251 | * @param cMaxEntriesPerGroup The max number of entries per group. UINT32_MAX
|
---|
2252 | * or zero for unlimited.
|
---|
2253 | * @param cBufDescs Number of buffer descriptors that @a paBufDescs
|
---|
2254 | * points to. Zero for defaults.
|
---|
2255 | * @param paBufDescs Buffer descriptors, optional.
|
---|
2256 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
2257 | * if pszFilenameFmt specified.
|
---|
2258 | * @param pfnPhase Callback function for starting logging and for
|
---|
2259 | * ending or starting a new file for log history
|
---|
2260 | * rotation.
|
---|
2261 | * @param cHistory Number of old log files to keep when performing
|
---|
2262 | * log history rotation. 0 means no history.
|
---|
2263 | * @param cbHistoryFileMax Maximum size of log file when performing
|
---|
2264 | * history rotation. 0 means no size limit.
|
---|
2265 | * @param cSecsHistoryTimeSlot Maximum time interval per log file when
|
---|
2266 | * performing history rotation, in seconds.
|
---|
2267 | * 0 means no time limit.
|
---|
2268 | * @param pOutputIf The optional file output interface, can be NULL which will
|
---|
2269 | * make use of the default one.
|
---|
2270 | * @param pvOutputIfUser The opaque user data to pass to the callbacks in the output interface.
|
---|
2271 | * @param pErrInfo Where to return extended error information.
|
---|
2272 | * Optional.
|
---|
2273 | * @param pszFilenameFmt Log filename format string. Standard
|
---|
2274 | * RTStrFormat().
|
---|
2275 | * @param va Format arguments.
|
---|
2276 | */
|
---|
2277 | RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, const char *pszEnvVarBase, uint64_t fFlags, const char *pszGroupSettings,
|
---|
2278 | uint32_t cGroups, const char * const *papszGroups, uint32_t cMaxEntriesPerGroup,
|
---|
2279 | uint32_t cBufDescs, PRTLOGBUFFERDESC paBufDescs, uint32_t fDestFlags,
|
---|
2280 | PFNRTLOGPHASE pfnPhase, uint32_t cHistory, uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
|
---|
2281 | PCRTLOGOUTPUTIF pOutputIf, void *pvOutputIfUser,
|
---|
2282 | PRTERRINFO pErrInfo, const char *pszFilenameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(18, 0);
|
---|
2283 |
|
---|
2284 | /**
|
---|
2285 | * Destroys a logger instance.
|
---|
2286 | *
|
---|
2287 | * The instance is flushed and all output destinations closed (where applicable).
|
---|
2288 | *
|
---|
2289 | * @returns iprt status code.
|
---|
2290 | * @param pLogger The logger instance which close destroyed. NULL is fine.
|
---|
2291 | */
|
---|
2292 | RTDECL(int) RTLogDestroy(PRTLOGGER pLogger);
|
---|
2293 |
|
---|
2294 | /**
|
---|
2295 | * Sets the custom prefix callback.
|
---|
2296 | *
|
---|
2297 | * @returns IPRT status code.
|
---|
2298 | * @param pLogger The logger instance.
|
---|
2299 | * @param pfnCallback The callback.
|
---|
2300 | * @param pvUser The user argument for the callback.
|
---|
2301 | * */
|
---|
2302 | RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger, PFNRTLOGPREFIX pfnCallback, void *pvUser);
|
---|
2303 |
|
---|
2304 | /**
|
---|
2305 | * Sets the custom flush callback.
|
---|
2306 | *
|
---|
2307 | * This can be handy for special loggers like the per-EMT ones in ring-0,
|
---|
2308 | * but also for implementing a log viewer in the debugger GUI.
|
---|
2309 | *
|
---|
2310 | * @returns IPRT status code.
|
---|
2311 | * @retval VWRN_ALREADY_EXISTS if it was set to a different flusher.
|
---|
2312 | * @param pLogger The logger instance.
|
---|
2313 | * @param pfnFlush The flush callback.
|
---|
2314 | */
|
---|
2315 | RTDECL(int) RTLogSetFlushCallback(PRTLOGGER pLogger, PFNRTLOGFLUSH pfnFlush);
|
---|
2316 |
|
---|
2317 | /**
|
---|
2318 | * Sets the thread name for a thread specific ring-0 logger.
|
---|
2319 | *
|
---|
2320 | * @returns IPRT status code.
|
---|
2321 | * @param pLogger The logger. NULL is not allowed.
|
---|
2322 | * @param pszNameFmt The format string for the thread name.
|
---|
2323 | * @param ... Format arguments.
|
---|
2324 | */
|
---|
2325 | RTR0DECL(int) RTLogSetR0ThreadNameF(PRTLOGGER pLogger, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
|
---|
2326 |
|
---|
2327 | /**
|
---|
2328 | * Sets the thread name for a thread specific ring-0 logger.
|
---|
2329 | *
|
---|
2330 | * @returns IPRT status code.
|
---|
2331 | * @param pLogger The logger. NULL is not allowed.
|
---|
2332 | * @param pszNameFmt The format string for the thread name.
|
---|
2333 | * @param va Format arguments.
|
---|
2334 | */
|
---|
2335 | RTR0DECL(int) RTLogSetR0ThreadNameV(PRTLOGGER pLogger, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
|
---|
2336 |
|
---|
2337 | /**
|
---|
2338 | * Sets the program start time for a thread specific ring-0 logger.
|
---|
2339 | *
|
---|
2340 | * @returns IPRT status code.
|
---|
2341 | * @param pLogger The logger. NULL is not allowed.
|
---|
2342 | * @param nsStart The RTTimeNanoTS() value at program start.
|
---|
2343 | */
|
---|
2344 | RTR0DECL(int) RTLogSetR0ProgramStart(PRTLOGGER pLogger, uint64_t nsStart);
|
---|
2345 |
|
---|
2346 | /**
|
---|
2347 | * Get the current log group settings as a string.
|
---|
2348 | *
|
---|
2349 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
2350 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2351 | * @param pszBuf The output buffer.
|
---|
2352 | * @param cchBuf The size of the output buffer. Must be greater than
|
---|
2353 | * zero.
|
---|
2354 | */
|
---|
2355 | RTDECL(int) RTLogQueryGroupSettings(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
2356 |
|
---|
2357 | /**
|
---|
2358 | * Updates the group settings for the logger instance using the specified
|
---|
2359 | * specification string.
|
---|
2360 | *
|
---|
2361 | * @returns iprt status code.
|
---|
2362 | * Failures can safely be ignored.
|
---|
2363 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2364 | * @param pszValue Value to parse.
|
---|
2365 | */
|
---|
2366 | RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger, const char *pszValue);
|
---|
2367 |
|
---|
2368 | /**
|
---|
2369 | * Sets the max number of entries per group.
|
---|
2370 | *
|
---|
2371 | * @returns Old restriction.
|
---|
2372 | *
|
---|
2373 | * @param pLogger The logger instance (NULL is an alias for the
|
---|
2374 | * default logger).
|
---|
2375 | * @param cMaxEntriesPerGroup The max number of entries per group.
|
---|
2376 | *
|
---|
2377 | * @remarks Lowering the limit of an active logger may quietly mute groups.
|
---|
2378 | * Raising it may reactive already muted groups.
|
---|
2379 | */
|
---|
2380 | RTDECL(uint32_t) RTLogSetGroupLimit(PRTLOGGER pLogger, uint32_t cMaxEntriesPerGroup);
|
---|
2381 |
|
---|
2382 | /**
|
---|
2383 | * Gets the current flag settings for the given logger.
|
---|
2384 | *
|
---|
2385 | * @returns Logger flags, UINT64_MAX if no logger.
|
---|
2386 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2387 | */
|
---|
2388 | RTDECL(uint64_t) RTLogGetFlags(PRTLOGGER pLogger);
|
---|
2389 |
|
---|
2390 | /**
|
---|
2391 | * Modifies the flag settings for the given logger.
|
---|
2392 | *
|
---|
2393 | * @returns IPRT status code. Returns VINF_LOG_NO_LOGGER if no default logger
|
---|
2394 | * and @a pLogger is NULL.
|
---|
2395 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2396 | * @param fSet Mask of flags to set (OR).
|
---|
2397 | * @param fClear Mask of flags to clear (NAND). This is allowed to
|
---|
2398 | * include invalid flags - e.g. UINT64_MAX is okay.
|
---|
2399 | */
|
---|
2400 | RTDECL(int) RTLogChangeFlags(PRTLOGGER pLogger, uint64_t fSet, uint64_t fClear);
|
---|
2401 |
|
---|
2402 | /**
|
---|
2403 | * Updates the flags for the logger instance using the specified
|
---|
2404 | * specification string.
|
---|
2405 | *
|
---|
2406 | * @returns iprt status code.
|
---|
2407 | * Failures can safely be ignored.
|
---|
2408 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2409 | * @param pszValue Value to parse.
|
---|
2410 | */
|
---|
2411 | RTDECL(int) RTLogFlags(PRTLOGGER pLogger, const char *pszValue);
|
---|
2412 |
|
---|
2413 | /**
|
---|
2414 | * Changes the buffering setting of the specified logger.
|
---|
2415 | *
|
---|
2416 | * This can be used for optimizing longish logging sequences.
|
---|
2417 | *
|
---|
2418 | * @returns The old state.
|
---|
2419 | * @param pLogger The logger instance (NULL is an alias for the default
|
---|
2420 | * logger).
|
---|
2421 | * @param fBuffered The new state.
|
---|
2422 | */
|
---|
2423 | RTDECL(bool) RTLogSetBuffering(PRTLOGGER pLogger, bool fBuffered);
|
---|
2424 |
|
---|
2425 | /**
|
---|
2426 | * Get the current log flags as a string.
|
---|
2427 | *
|
---|
2428 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
2429 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2430 | * @param pszBuf The output buffer.
|
---|
2431 | * @param cchBuf The size of the output buffer. Must be greater than
|
---|
2432 | * zero.
|
---|
2433 | */
|
---|
2434 | RTDECL(int) RTLogQueryFlags(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
2435 |
|
---|
2436 | /**
|
---|
2437 | * Gets the current destinations flags for the given logger.
|
---|
2438 | *
|
---|
2439 | * @returns Logger destination flags, UINT32_MAX if no logger.
|
---|
2440 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2441 | */
|
---|
2442 | RTDECL(uint32_t) RTLogGetDestinations(PRTLOGGER pLogger);
|
---|
2443 |
|
---|
2444 | /**
|
---|
2445 | * Modifies the log destinations settings for the given logger.
|
---|
2446 | *
|
---|
2447 | * This is only suitable for simple destination settings that doesn't take
|
---|
2448 | * additional arguments, like RTLOGDEST_FILE.
|
---|
2449 | *
|
---|
2450 | * @returns IPRT status code. Returns VINF_LOG_NO_LOGGER if no default logger
|
---|
2451 | * and @a pLogger is NULL.
|
---|
2452 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2453 | * @param fSet Mask of destinations to set (OR).
|
---|
2454 | * @param fClear Mask of destinations to clear (NAND).
|
---|
2455 | */
|
---|
2456 | RTDECL(int) RTLogChangeDestinations(PRTLOGGER pLogger, uint32_t fSet, uint32_t fClear);
|
---|
2457 |
|
---|
2458 | /**
|
---|
2459 | * Updates the logger destination using the specified string.
|
---|
2460 | *
|
---|
2461 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
2462 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2463 | * @param pszValue The value to parse.
|
---|
2464 | */
|
---|
2465 | RTDECL(int) RTLogDestinations(PRTLOGGER pLogger, char const *pszValue);
|
---|
2466 |
|
---|
2467 | /**
|
---|
2468 | * Clear the file delay flag if set, opening the destination and flushing.
|
---|
2469 | *
|
---|
2470 | * @returns IPRT status code.
|
---|
2471 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2472 | * @param pErrInfo Where to return extended error info. Optional.
|
---|
2473 | */
|
---|
2474 | RTDECL(int) RTLogClearFileDelayFlag(PRTLOGGER pLogger, PRTERRINFO pErrInfo);
|
---|
2475 |
|
---|
2476 | /**
|
---|
2477 | * Get the current log destinations as a string.
|
---|
2478 | *
|
---|
2479 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
2480 | * @param pLogger Logger instance (NULL for default logger).
|
---|
2481 | * @param pszBuf The output buffer.
|
---|
2482 | * @param cchBuf The size of the output buffer. Must be greater than 0.
|
---|
2483 | */
|
---|
2484 | RTDECL(int) RTLogQueryDestinations(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
2485 |
|
---|
2486 | /**
|
---|
2487 | * Performs a bulk update of logger flags and group flags.
|
---|
2488 | *
|
---|
2489 | * This is for instanced used for copying settings from ring-3 to ring-0
|
---|
2490 | * loggers.
|
---|
2491 | *
|
---|
2492 | * @returns IPRT status code.
|
---|
2493 | * @param pLogger The logger instance (NULL for default logger).
|
---|
2494 | * @param fFlags The new logger flags.
|
---|
2495 | * @param uGroupCrc32 The CRC32 of the group name strings.
|
---|
2496 | * @param cGroups Number of groups.
|
---|
2497 | * @param pafGroups Array of group flags.
|
---|
2498 | * @sa RTLogQueryBulk
|
---|
2499 | */
|
---|
2500 | RTDECL(int) RTLogBulkUpdate(PRTLOGGER pLogger, uint64_t fFlags, uint32_t uGroupCrc32, uint32_t cGroups, uint32_t const *pafGroups);
|
---|
2501 |
|
---|
2502 | /**
|
---|
2503 | * Queries data for a bulk update of logger flags and group flags.
|
---|
2504 | *
|
---|
2505 | * This is for instanced used for copying settings from ring-3 to ring-0
|
---|
2506 | * loggers.
|
---|
2507 | *
|
---|
2508 | * @returns IPRT status code.
|
---|
2509 | * @retval VERR_BUFFER_OVERFLOW if pafGroups is too small, @a pcGroups will be
|
---|
2510 | * set to the actual number of groups.
|
---|
2511 | * @param pLogger The logger instance (NULL for default logger).
|
---|
2512 | * @param pfFlags Where to return the logger flags.
|
---|
2513 | * @param puGroupCrc32 Where to return the CRC32 of the group names.
|
---|
2514 | * @param pcGroups Input: Size of the @a pafGroups allocation.
|
---|
2515 | * Output: Actual number of groups returned.
|
---|
2516 | * @param pafGroups Where to return the flags for each group.
|
---|
2517 | * @sa RTLogBulkUpdate
|
---|
2518 | */
|
---|
2519 | RTDECL(int) RTLogQueryBulk(PRTLOGGER pLogger, uint64_t *pfFlags, uint32_t *puGroupCrc32, uint32_t *pcGroups, uint32_t *pafGroups);
|
---|
2520 |
|
---|
2521 | /**
|
---|
2522 | * Write/copy bulk log data from another logger.
|
---|
2523 | *
|
---|
2524 | * This is used for transferring stuff from the ring-0 loggers and into the
|
---|
2525 | * ring-3 one. The text goes in as-is w/o any processing (i.e. prefixing or
|
---|
2526 | * newline fun).
|
---|
2527 | *
|
---|
2528 | * @returns IRPT status code.
|
---|
2529 | * @param pLogger The logger instance (NULL for default logger).
|
---|
2530 | * @param pszBefore Text to log before the bulk text. Optional.
|
---|
2531 | * @param pch Pointer to the block of bulk log text to write.
|
---|
2532 | * @param cch Size of the block of bulk log text to write.
|
---|
2533 | * @param pszAfter Text to log after the bulk text. Optional.
|
---|
2534 | */
|
---|
2535 | RTDECL(int) RTLogBulkWrite(PRTLOGGER pLogger, const char *pszBefore, const char *pch, size_t cch, const char *pszAfter);
|
---|
2536 |
|
---|
2537 | /**
|
---|
2538 | * Write/copy bulk log data from a nested VM logger.
|
---|
2539 | *
|
---|
2540 | * This is used for
|
---|
2541 | *
|
---|
2542 | * @returns IRPT status code.
|
---|
2543 | * @param pLogger The logger instance (NULL for default logger).
|
---|
2544 | * @param pch Pointer to the block of bulk log text to write.
|
---|
2545 | * @param cch Size of the block of bulk log text to write.
|
---|
2546 | * @param pszInfix String to put after the line prefixes and the
|
---|
2547 | * line content.
|
---|
2548 | */
|
---|
2549 | RTDECL(int) RTLogBulkNestedWrite(PRTLOGGER pLogger, const char *pch, size_t cch, const char *pszInfix);
|
---|
2550 |
|
---|
2551 | /**
|
---|
2552 | * Flushes the specified logger.
|
---|
2553 | *
|
---|
2554 | * @returns IRPT status code.
|
---|
2555 | * @param pLogger The logger instance to flush.
|
---|
2556 | * If NULL the default instance is used. The default instance
|
---|
2557 | * will not be initialized by this call.
|
---|
2558 | */
|
---|
2559 | RTDECL(int) RTLogFlush(PRTLOGGER pLogger);
|
---|
2560 |
|
---|
2561 | /**
|
---|
2562 | * Write to a logger instance.
|
---|
2563 | *
|
---|
2564 | * @param pLogger Pointer to logger instance.
|
---|
2565 | * @param pvCallerRet Ignored.
|
---|
2566 | * @param pszFormat Format string.
|
---|
2567 | * @param ... Format arguments.
|
---|
2568 | */
|
---|
2569 | RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
2570 |
|
---|
2571 | /**
|
---|
2572 | * Write to a logger instance, weak version.
|
---|
2573 | *
|
---|
2574 | * @param pLogger Pointer to logger instance.
|
---|
2575 | * @param pvCallerRet Ignored.
|
---|
2576 | * @param pszFormat Format string.
|
---|
2577 | * @param ... Format arguments.
|
---|
2578 | */
|
---|
2579 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
2580 | RTDECL(void) RTLogLoggerWeak(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
2581 | #else /* Cannot use a DECL_FORCE_INLINE because older GCC versions doesn't support inlining va_start. */
|
---|
2582 | # undef RTLogLoggerWeak /* in case of mangling */
|
---|
2583 | # define RTLogLoggerWeak RTLogLogger
|
---|
2584 | #endif
|
---|
2585 |
|
---|
2586 | /**
|
---|
2587 | * Write to a logger instance.
|
---|
2588 | *
|
---|
2589 | * @param pLogger Pointer to logger instance.
|
---|
2590 | * @param pszFormat Format string.
|
---|
2591 | * @param args Format arguments.
|
---|
2592 | */
|
---|
2593 | RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(2, 0);
|
---|
2594 |
|
---|
2595 | /**
|
---|
2596 | * Write to a logger instance.
|
---|
2597 | *
|
---|
2598 | * This function will check whether the instance, group and flags makes up a
|
---|
2599 | * logging kind which is currently enabled before writing anything to the log.
|
---|
2600 | *
|
---|
2601 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
2602 | * @param fFlags The logging flags.
|
---|
2603 | * @param iGroup The group.
|
---|
2604 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
2605 | * only for internal usage!
|
---|
2606 | * @param pszFormat Format string.
|
---|
2607 | * @param ... Format arguments.
|
---|
2608 | * @remark This is a worker function of LogIt.
|
---|
2609 | */
|
---|
2610 | RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
2611 | const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
|
---|
2612 |
|
---|
2613 | /**
|
---|
2614 | * Write to a logger instance, weak version.
|
---|
2615 | *
|
---|
2616 | * This function will check whether the instance, group and flags makes up a
|
---|
2617 | * logging kind which is currently enabled before writing anything to the log.
|
---|
2618 | *
|
---|
2619 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
2620 | * @param fFlags The logging flags.
|
---|
2621 | * @param iGroup The group.
|
---|
2622 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
2623 | * only for internal usage!
|
---|
2624 | * @param pszFormat Format string.
|
---|
2625 | * @param ... Format arguments.
|
---|
2626 | * @remark This is a worker function of LogIt.
|
---|
2627 | */
|
---|
2628 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
2629 | RTDECL(void) RTLogLoggerExWeak(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
2630 | const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
|
---|
2631 | #else /* Cannot use a DECL_FORCE_INLINE because older GCC versions doesn't support inlining va_start. */
|
---|
2632 | # undef RTLogLoggerExWeak /* in case of mangling */
|
---|
2633 | # define RTLogLoggerExWeak RTLogLoggerEx
|
---|
2634 | #endif
|
---|
2635 |
|
---|
2636 | /**
|
---|
2637 | * Write to a logger instance.
|
---|
2638 | *
|
---|
2639 | * This function will check whether the instance, group and flags makes up a
|
---|
2640 | * logging kind which is currently enabled before writing anything to the log.
|
---|
2641 | *
|
---|
2642 | * @returns VINF_SUCCESS, VINF_LOG_NO_LOGGER, VINF_LOG_DISABLED, or IPRT error
|
---|
2643 | * status.
|
---|
2644 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
2645 | * @param fFlags The logging flags.
|
---|
2646 | * @param iGroup The group.
|
---|
2647 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
2648 | * only for internal usage!
|
---|
2649 | * @param pszFormat Format string.
|
---|
2650 | * @param args Format arguments.
|
---|
2651 | */
|
---|
2652 | RTDECL(int) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
2653 | const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
|
---|
2654 |
|
---|
2655 | /** @copydoc RTLogLoggerExV */
|
---|
2656 | typedef DECLCALLBACKTYPE(int, FNRTLOGLOGGEREXV,(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
2657 | const char *pszFormat, va_list args)) RT_IPRT_FORMAT_ATTR(4, 0);
|
---|
2658 | /** Pointer to RTLogLoggerExV. */
|
---|
2659 | typedef FNRTLOGLOGGEREXV *PFNRTLOGLOGGEREXV;
|
---|
2660 | /** "Weak symbol" emulation for RTLogLoggerExV.
|
---|
2661 | * @note This is first set when RTLogCreateEx or RTLogCreate is called. */
|
---|
2662 | extern RTDATADECL(PFNRTLOGLOGGEREXV) g_pfnRTLogLoggerExV;
|
---|
2663 |
|
---|
2664 | /** "Weak symbol" wrapper for RTLogLoggerExV. */
|
---|
2665 | DECL_FORCE_INLINE(int) RTLogLoggerExVWeak(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
|
---|
2666 | const char *pszFormat, va_list args) /* RT_IPRT_FORMAT_ATTR(4, 0) */
|
---|
2667 | {
|
---|
2668 | #if defined(IN_RING3) && (defined(IN_RT_STATIC) || defined(IPRT_NO_CRT))
|
---|
2669 | if (g_pfnRTLogLoggerExV)
|
---|
2670 | return g_pfnRTLogLoggerExV(pLogger, fFlags, iGroup, pszFormat, args);
|
---|
2671 | return 22301; /* VINF_LOG_DISABLED, don't want err.h dependency here. */
|
---|
2672 | #else
|
---|
2673 | return RTLogLoggerExV(pLogger, fFlags, iGroup, pszFormat, args);
|
---|
2674 | #endif
|
---|
2675 | }
|
---|
2676 |
|
---|
2677 | /**
|
---|
2678 | * printf like function for writing to the default log.
|
---|
2679 | *
|
---|
2680 | * @param pszFormat Printf like format string.
|
---|
2681 | * @param ... Optional arguments as specified in pszFormat.
|
---|
2682 | *
|
---|
2683 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
2684 | */
|
---|
2685 | RTDECL(void) RTLogPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
2686 |
|
---|
2687 | /**
|
---|
2688 | * vprintf like function for writing to the default log.
|
---|
2689 | *
|
---|
2690 | * @param pszFormat Printf like format string.
|
---|
2691 | * @param va Optional arguments as specified in pszFormat.
|
---|
2692 | *
|
---|
2693 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
2694 | */
|
---|
2695 | RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
2696 |
|
---|
2697 | /**
|
---|
2698 | * Dumper vprintf-like function outputting to a logger.
|
---|
2699 | *
|
---|
2700 | * @param pvUser Pointer to the logger instance to use, NULL for default
|
---|
2701 | * instance.
|
---|
2702 | * @param pszFormat Format string.
|
---|
2703 | * @param va Format arguments.
|
---|
2704 | */
|
---|
2705 | RTDECL(void) RTLogDumpPrintfV(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
|
---|
2706 |
|
---|
2707 | /**
|
---|
2708 | * Used for logging assertions, debug and release log as appropriate.
|
---|
2709 | *
|
---|
2710 | * Implies flushing.
|
---|
2711 | *
|
---|
2712 | * @param pszFormat Format string.
|
---|
2713 | * @param ... Format arguments.
|
---|
2714 | */
|
---|
2715 | typedef DECLCALLBACKTYPE(void, FNRTLOGASSERTION,(const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
2716 | /** Pointer to an assertion logger, ellipsis variant. */
|
---|
2717 | typedef FNRTLOGASSERTION *PFNRTLOGASSERTION;
|
---|
2718 |
|
---|
2719 | /**
|
---|
2720 | * Used for logging assertions, debug and release log as appropriate.
|
---|
2721 | *
|
---|
2722 | * Implies flushing.
|
---|
2723 | *
|
---|
2724 | * @param pszFormat Format string.
|
---|
2725 | * @param va Format arguments.
|
---|
2726 | */
|
---|
2727 | typedef DECLCALLBACKTYPE(void, FNRTLOGASSERTIONV,(const char *pszFormat, va_list va)) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
2728 | /** Pointer to an assertion logger, va_list variant. */
|
---|
2729 | typedef FNRTLOGASSERTIONV *PFNRTLOGASSERTIONV;
|
---|
2730 |
|
---|
2731 | /** @copydoc FNRTLOGASSERTION */
|
---|
2732 | RTDECL(void) RTLogAssert(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
2733 | /** @copydoc FNRTLOGASSERTIONV */
|
---|
2734 | RTDECL(void) RTLogAssertV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
2735 |
|
---|
2736 | /** "Weak symbol" emulation for RTLogAssert. */
|
---|
2737 | extern RTDATADECL(PFNRTLOGASSERTION) g_pfnRTLogAssert;
|
---|
2738 | /** "Weak symbol" emulation for RTLogAssertV. */
|
---|
2739 | extern RTDATADECL(PFNRTLOGASSERTIONV) g_pfnRTLogAssertV;
|
---|
2740 |
|
---|
2741 |
|
---|
2742 | #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h & iprt/errcore.h */
|
---|
2743 | #define DECLARED_FNRTSTROUTPUT
|
---|
2744 | /**
|
---|
2745 | * Output callback.
|
---|
2746 | *
|
---|
2747 | * @returns number of bytes written.
|
---|
2748 | * @param pvArg User argument.
|
---|
2749 | * @param pachChars Pointer to an array of utf-8 characters.
|
---|
2750 | * @param cbChars Number of bytes in the character array pointed to by pachChars.
|
---|
2751 | */
|
---|
2752 | typedef DECLCALLBACKTYPE(size_t, FNRTSTROUTPUT,(void *pvArg, const char *pachChars, size_t cbChars));
|
---|
2753 | /** Pointer to callback function. */
|
---|
2754 | typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
|
---|
2755 | #endif
|
---|
2756 |
|
---|
2757 | /**
|
---|
2758 | * Partial vsprintf worker implementation.
|
---|
2759 | *
|
---|
2760 | * @returns number of bytes formatted.
|
---|
2761 | * @param pfnOutput Output worker.
|
---|
2762 | * Called in two ways. Normally with a string an it's length.
|
---|
2763 | * For termination, it's called with NULL for string, 0 for length.
|
---|
2764 | * @param pvArg Argument to output worker.
|
---|
2765 | * @param pszFormat Format string.
|
---|
2766 | * @param args Argument list.
|
---|
2767 | */
|
---|
2768 | RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(3, 0);
|
---|
2769 |
|
---|
2770 | /**
|
---|
2771 | * Write log buffer to COM port.
|
---|
2772 | *
|
---|
2773 | * @param pach Pointer to the buffer to write.
|
---|
2774 | * @param cb Number of bytes to write.
|
---|
2775 | */
|
---|
2776 | RTDECL(void) RTLogWriteCom(const char *pach, size_t cb);
|
---|
2777 |
|
---|
2778 | /**
|
---|
2779 | * Prints a formatted string to the serial port used for logging.
|
---|
2780 | *
|
---|
2781 | * @returns Number of bytes written.
|
---|
2782 | * @param pszFormat Format string.
|
---|
2783 | * @param ... Optional arguments specified in the format string.
|
---|
2784 | */
|
---|
2785 | RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
2786 |
|
---|
2787 | /**
|
---|
2788 | * Prints a formatted string to the serial port used for logging.
|
---|
2789 | *
|
---|
2790 | * @returns Number of bytes written.
|
---|
2791 | * @param pszFormat Format string.
|
---|
2792 | * @param args Optional arguments specified in the format string.
|
---|
2793 | */
|
---|
2794 | RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
2795 |
|
---|
2796 | /**
|
---|
2797 | * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
|
---|
2798 | *
|
---|
2799 | * @param pach What to write.
|
---|
2800 | * @param cb How much to write.
|
---|
2801 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2802 | */
|
---|
2803 | RTDECL(void) RTLogWriteDebugger(const char *pach, size_t cb);
|
---|
2804 |
|
---|
2805 | /**
|
---|
2806 | * Write log buffer to a user defined output stream (RTLOGDEST_USER).
|
---|
2807 | *
|
---|
2808 | * @param pach What to write.
|
---|
2809 | * @param cb How much to write.
|
---|
2810 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2811 | */
|
---|
2812 | RTDECL(void) RTLogWriteUser(const char *pach, size_t cb);
|
---|
2813 |
|
---|
2814 | /**
|
---|
2815 | * Write log buffer to a parent VMM (hypervisor).
|
---|
2816 | *
|
---|
2817 | * @param pach What to write.
|
---|
2818 | * @param cb How much to write.
|
---|
2819 | * @param fRelease Set if targeting the release log, clear if debug log.
|
---|
2820 | *
|
---|
2821 | * @note Currently only available on AMD64 and x86.
|
---|
2822 | */
|
---|
2823 | RTDECL(void) RTLogWriteVmm(const char *pach, size_t cb, bool fRelease);
|
---|
2824 |
|
---|
2825 | /**
|
---|
2826 | * Write log buffer to stdout (RTLOGDEST_STDOUT).
|
---|
2827 | *
|
---|
2828 | * @param pach What to write.
|
---|
2829 | * @param cb How much to write.
|
---|
2830 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2831 | */
|
---|
2832 | RTDECL(void) RTLogWriteStdOut(const char *pach, size_t cb);
|
---|
2833 |
|
---|
2834 | /**
|
---|
2835 | * Write log buffer to stdout (RTLOGDEST_STDERR).
|
---|
2836 | *
|
---|
2837 | * @param pach What to write.
|
---|
2838 | * @param cb How much to write.
|
---|
2839 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2840 | */
|
---|
2841 | RTDECL(void) RTLogWriteStdErr(const char *pach, size_t cb);
|
---|
2842 |
|
---|
2843 | #ifdef VBOX
|
---|
2844 |
|
---|
2845 | /**
|
---|
2846 | * Prints a formatted string to the backdoor port.
|
---|
2847 | *
|
---|
2848 | * @returns Number of bytes written.
|
---|
2849 | * @param pszFormat Format string.
|
---|
2850 | * @param ... Optional arguments specified in the format string.
|
---|
2851 | */
|
---|
2852 | RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
2853 |
|
---|
2854 | /**
|
---|
2855 | * Prints a formatted string to the backdoor port.
|
---|
2856 | *
|
---|
2857 | * @returns Number of bytes written.
|
---|
2858 | * @param pszFormat Format string.
|
---|
2859 | * @param args Optional arguments specified in the format string.
|
---|
2860 | */
|
---|
2861 | RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
|
---|
2862 |
|
---|
2863 | #endif /* VBOX */
|
---|
2864 |
|
---|
2865 | RT_C_DECLS_END
|
---|
2866 |
|
---|
2867 | /** @} */
|
---|
2868 |
|
---|
2869 | #endif /* !IPRT_INCLUDED_log_h */
|
---|
2870 |
|
---|