1 | /** @file
|
---|
2 | * IPRT - Logging.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2012 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_log_h
|
---|
27 | #define ___iprt_log_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/stdarg.h>
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | /** @defgroup grp_rt_log RTLog - Logging
|
---|
36 | * @ingroup grp_rt
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * IPRT Logging Groups.
|
---|
42 | * (Remember to update RT_LOGGROUP_NAMES!)
|
---|
43 | *
|
---|
44 | * @remark It should be pretty obvious, but just to have
|
---|
45 | * mentioned it, the values are sorted alphabetically (using the
|
---|
46 | * english alphabet) except for _DEFAULT which is always first.
|
---|
47 | *
|
---|
48 | * If anyone might be wondering what the alphabet looks like:
|
---|
49 | * 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
|
---|
50 | */
|
---|
51 | typedef enum RTLOGGROUP
|
---|
52 | {
|
---|
53 | /** Default logging group. */
|
---|
54 | RTLOGGROUP_DEFAULT,
|
---|
55 | RTLOGGROUP_DBG,
|
---|
56 | RTLOGGROUP_DBG_DWARF,
|
---|
57 | RTLOGGROUP_DIR,
|
---|
58 | RTLOGGROUP_FILE,
|
---|
59 | RTLOGGROUP_FS,
|
---|
60 | RTLOGGROUP_LDR,
|
---|
61 | RTLOGGROUP_PATH,
|
---|
62 | RTLOGGROUP_PROCESS,
|
---|
63 | RTLOGGROUP_SYMLINK,
|
---|
64 | RTLOGGROUP_THREAD,
|
---|
65 | RTLOGGROUP_TIME,
|
---|
66 | RTLOGGROUP_TIMER,
|
---|
67 | RTLOGGROUP_ZIP = 31,
|
---|
68 | RTLOGGROUP_FIRST_USER = 32
|
---|
69 | } RTLOGGROUP;
|
---|
70 |
|
---|
71 | /** @def RT_LOGGROUP_NAMES
|
---|
72 | * IPRT Logging group names.
|
---|
73 | *
|
---|
74 | * Must correspond 100% to RTLOGGROUP!
|
---|
75 | * Don't forget commas!
|
---|
76 | *
|
---|
77 | * @remark It should be pretty obvious, but just to have
|
---|
78 | * mentioned it, the values are sorted alphabetically (using the
|
---|
79 | * english alphabet) except for _DEFAULT which is always first.
|
---|
80 | *
|
---|
81 | * If anyone might be wondering what the alphabet looks like:
|
---|
82 | * 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
|
---|
83 | */
|
---|
84 | #define RT_LOGGROUP_NAMES \
|
---|
85 | "DEFAULT", \
|
---|
86 | "RT_DBG", \
|
---|
87 | "RT_DBG_DWARF", \
|
---|
88 | "RT_DIR", \
|
---|
89 | "RT_FILE", \
|
---|
90 | "RT_FS", \
|
---|
91 | "RT_LDR", \
|
---|
92 | "RT_PATH", \
|
---|
93 | "RT_PROCESS", \
|
---|
94 | "RT_SYMLINK", \
|
---|
95 | "RT_THREAD", \
|
---|
96 | "RT_TIME", \
|
---|
97 | "RT_TIMER", \
|
---|
98 | "RT_13", \
|
---|
99 | "RT_14", \
|
---|
100 | "RT_15", \
|
---|
101 | "RT_16", \
|
---|
102 | "RT_17", \
|
---|
103 | "RT_18", \
|
---|
104 | "RT_19", \
|
---|
105 | "RT_20", \
|
---|
106 | "RT_21", \
|
---|
107 | "RT_22", \
|
---|
108 | "RT_23", \
|
---|
109 | "RT_24", \
|
---|
110 | "RT_25", \
|
---|
111 | "RT_26", \
|
---|
112 | "RT_27", \
|
---|
113 | "RT_28", \
|
---|
114 | "RT_29", \
|
---|
115 | "RT_30", \
|
---|
116 | "RT_ZIP" \
|
---|
117 |
|
---|
118 |
|
---|
119 | /** @def LOG_GROUP
|
---|
120 | * Active logging group.
|
---|
121 | */
|
---|
122 | #ifndef LOG_GROUP
|
---|
123 | # define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | /** @def LOG_INSTANCE
|
---|
127 | * Active logging instance.
|
---|
128 | */
|
---|
129 | #ifndef LOG_INSTANCE
|
---|
130 | # define LOG_INSTANCE NULL
|
---|
131 | #endif
|
---|
132 |
|
---|
133 | /** @def LOG_REL_INSTANCE
|
---|
134 | * Active release logging instance.
|
---|
135 | */
|
---|
136 | #ifndef LOG_REL_INSTANCE
|
---|
137 | # define LOG_REL_INSTANCE NULL
|
---|
138 | #endif
|
---|
139 |
|
---|
140 | /** @def LOG_FN_FMT
|
---|
141 | * You can use this to specify you desired way of printing __PRETTY_FUNCTION__
|
---|
142 | * if you dislike the default one.
|
---|
143 | */
|
---|
144 | #ifndef LOG_FN_FMT
|
---|
145 | # define LOG_FN_FMT "%Rfn"
|
---|
146 | #endif
|
---|
147 |
|
---|
148 | /** Logger structure. */
|
---|
149 | #ifdef IN_RC
|
---|
150 | typedef struct RTLOGGERRC RTLOGGER;
|
---|
151 | #else
|
---|
152 | typedef struct RTLOGGER RTLOGGER;
|
---|
153 | #endif
|
---|
154 | /** Pointer to logger structure. */
|
---|
155 | typedef RTLOGGER *PRTLOGGER;
|
---|
156 | /** Pointer to const logger structure. */
|
---|
157 | typedef const RTLOGGER *PCRTLOGGER;
|
---|
158 |
|
---|
159 |
|
---|
160 | /** Guest context logger structure. */
|
---|
161 | typedef struct RTLOGGERRC RTLOGGERRC;
|
---|
162 | /** Pointer to guest context logger structure. */
|
---|
163 | typedef RTLOGGERRC *PRTLOGGERRC;
|
---|
164 | /** Pointer to const guest context logger structure. */
|
---|
165 | typedef const RTLOGGERRC *PCRTLOGGERRC;
|
---|
166 |
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Logger phase.
|
---|
170 | *
|
---|
171 | * Used for signalling the log header/footer callback what to do.
|
---|
172 | */
|
---|
173 | typedef enum RTLOGPHASE
|
---|
174 | {
|
---|
175 | /** Begin of the logging. */
|
---|
176 | RTLOGPHASE_BEGIN = 0,
|
---|
177 | /** End of the logging. */
|
---|
178 | RTLOGPHASE_END,
|
---|
179 | /** Before rotating the log file. */
|
---|
180 | RTLOGPHASE_PREROTATE,
|
---|
181 | /** After rotating the log file. */
|
---|
182 | RTLOGPHASE_POSTROTATE,
|
---|
183 | /** 32-bit type blow up hack. */
|
---|
184 | RTLOGPHASE_32BIT_HACK = 0x7fffffff
|
---|
185 | } RTLOGPHASE;
|
---|
186 |
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * Logger function.
|
---|
190 | *
|
---|
191 | * @param pszFormat Format string.
|
---|
192 | * @param ... Optional arguments as specified in the format string.
|
---|
193 | */
|
---|
194 | typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...);
|
---|
195 | /** Pointer to logger function. */
|
---|
196 | typedef FNRTLOGGER *PFNRTLOGGER;
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Flush function.
|
---|
200 | *
|
---|
201 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
202 | */
|
---|
203 | typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger);
|
---|
204 | /** Pointer to flush function. */
|
---|
205 | typedef FNRTLOGFLUSH *PFNRTLOGFLUSH;
|
---|
206 |
|
---|
207 | /**
|
---|
208 | * Flush function.
|
---|
209 | *
|
---|
210 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
211 | */
|
---|
212 | typedef DECLCALLBACK(void) FNRTLOGFLUSHGC(PRTLOGGERRC pLogger);
|
---|
213 | /** Pointer to logger function. */
|
---|
214 | typedef RCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC;
|
---|
215 |
|
---|
216 | /**
|
---|
217 | * Header/footer message callback.
|
---|
218 | *
|
---|
219 | * @param pLogger Pointer to the logger instance.
|
---|
220 | * @param pszFormat Format string.
|
---|
221 | * @param ... Optional arguments specified in the format string.
|
---|
222 | */
|
---|
223 | typedef DECLCALLBACK(void) FNRTLOGPHASEMSG(PRTLOGGER pLogger, const char *pszFormat, ...);
|
---|
224 | /** Pointer to header/footer message callback function. */
|
---|
225 | typedef FNRTLOGPHASEMSG *PFNRTLOGPHASEMSG;
|
---|
226 |
|
---|
227 | /**
|
---|
228 | * Log file header/footer callback.
|
---|
229 | *
|
---|
230 | * @param pLogger Pointer to the logger instance.
|
---|
231 | * @param enmLogPhase Indicates at what time the callback is invoked.
|
---|
232 | * @param pfnLogPhaseMsg Callback for writing the header/footer (RTLogPrintf
|
---|
233 | * and others are out of bounds).
|
---|
234 | */
|
---|
235 | typedef DECLCALLBACK(void) FNRTLOGPHASE(PRTLOGGER pLogger, RTLOGPHASE enmLogPhase, PFNRTLOGPHASEMSG pfnLogPhaseMsg);
|
---|
236 | /** Pointer to log header/footer callback function. */
|
---|
237 | typedef FNRTLOGPHASE *PFNRTLOGPHASE;
|
---|
238 |
|
---|
239 | /**
|
---|
240 | * Custom log prefix callback.
|
---|
241 | *
|
---|
242 | *
|
---|
243 | * @returns The number of chars written.
|
---|
244 | *
|
---|
245 | * @param pLogger Pointer to the logger instance.
|
---|
246 | * @param pchBuf Output buffer pointer.
|
---|
247 | * No need to terminate the output.
|
---|
248 | * @param cchBuf The size of the output buffer.
|
---|
249 | * @param pvUser The user argument.
|
---|
250 | */
|
---|
251 | typedef DECLCALLBACK(size_t) FNRTLOGPREFIX(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser);
|
---|
252 | /** Pointer to prefix callback function. */
|
---|
253 | typedef FNRTLOGPREFIX *PFNRTLOGPREFIX;
|
---|
254 |
|
---|
255 |
|
---|
256 |
|
---|
257 | /**
|
---|
258 | * Logger instance structure for raw-mode context (RC).
|
---|
259 | */
|
---|
260 | struct RTLOGGERRC
|
---|
261 | {
|
---|
262 | /** Pointer to temporary scratch buffer.
|
---|
263 | * This is used to format the log messages. */
|
---|
264 | char achScratch[32768];
|
---|
265 | /** Current scratch buffer position. */
|
---|
266 | uint32_t offScratch;
|
---|
267 | /** This is set if a prefix is pending. */
|
---|
268 | bool fPendingPrefix;
|
---|
269 | bool afAlignment[3];
|
---|
270 | /** Pointer to the logger function.
|
---|
271 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
272 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
273 | * A very unfortunate hack to work around the missing variadic macro support in C++. */
|
---|
274 | RCPTRTYPE(PFNRTLOGGER) pfnLogger;
|
---|
275 | /** Pointer to the flush function. */
|
---|
276 | PFNRTLOGFLUSHGC pfnFlush;
|
---|
277 | /** Magic number (RTLOGGERRC_MAGIC). */
|
---|
278 | uint32_t u32Magic;
|
---|
279 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
280 | uint32_t fFlags;
|
---|
281 | /** Number of groups in the afGroups member. */
|
---|
282 | uint32_t cGroups;
|
---|
283 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
284 | * This member have variable length and may extend way beyond
|
---|
285 | * the declared size of 1 entry. */
|
---|
286 | uint32_t afGroups[1];
|
---|
287 | };
|
---|
288 |
|
---|
289 | /** RTLOGGERRC::u32Magic value. (John Rogers Searle) */
|
---|
290 | #define RTLOGGERRC_MAGIC 0x19320731
|
---|
291 |
|
---|
292 |
|
---|
293 |
|
---|
294 | #ifndef IN_RC
|
---|
295 |
|
---|
296 | /** Pointer to internal logger bits. */
|
---|
297 | typedef struct RTLOGGERINTERNAL *PRTLOGGERINTERNAL;
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Logger instance structure.
|
---|
301 | */
|
---|
302 | struct RTLOGGER
|
---|
303 | {
|
---|
304 | /** Pointer to temporary scratch buffer.
|
---|
305 | * This is used to format the log messages. */
|
---|
306 | char achScratch[49152];
|
---|
307 | /** Current scratch buffer position. */
|
---|
308 | uint32_t offScratch;
|
---|
309 | /** Magic number. */
|
---|
310 | uint32_t u32Magic;
|
---|
311 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
312 | uint32_t fFlags;
|
---|
313 | /** Destination flags - RTLOGDEST. */
|
---|
314 | uint32_t fDestFlags;
|
---|
315 | /** Pointer to the internal bits of the logger.
|
---|
316 | * (The memory is allocated in the same block as RTLOGGER.) */
|
---|
317 | PRTLOGGERINTERNAL pInt;
|
---|
318 | /** Pointer to the logger function (used in non-C99 mode only).
|
---|
319 | *
|
---|
320 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
321 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
322 | * A very unfortunate hack to work around the missing variadic macro
|
---|
323 | * support in older C++/C standards. (The memory is allocated using
|
---|
324 | * RTMemExecAlloc(), except for agnostic R0 code.) */
|
---|
325 | PFNRTLOGGER pfnLogger;
|
---|
326 | /** Number of groups in the afGroups and papszGroups members. */
|
---|
327 | uint32_t cGroups;
|
---|
328 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
329 | * This member have variable length and may extend way beyond
|
---|
330 | * the declared size of 1 entry. */
|
---|
331 | uint32_t afGroups[1];
|
---|
332 | };
|
---|
333 |
|
---|
334 | /** RTLOGGER::u32Magic value. (Avram Noam Chomsky) */
|
---|
335 | # define RTLOGGER_MAGIC UINT32_C(0x19281207)
|
---|
336 |
|
---|
337 | #endif /* !IN_RC */
|
---|
338 |
|
---|
339 |
|
---|
340 | /**
|
---|
341 | * Logger flags.
|
---|
342 | */
|
---|
343 | typedef enum RTLOGFLAGS
|
---|
344 | {
|
---|
345 | /** The logger instance is disabled for normal output. */
|
---|
346 | RTLOGFLAGS_DISABLED = 0x00000001,
|
---|
347 | /** The logger instance is using buffered output. */
|
---|
348 | RTLOGFLAGS_BUFFERED = 0x00000002,
|
---|
349 | /** The logger instance expands LF to CR/LF. */
|
---|
350 | RTLOGFLAGS_USECRLF = 0x00000010,
|
---|
351 | /** Append to the log destination where applicable. */
|
---|
352 | RTLOGFLAGS_APPEND = 0x00000020,
|
---|
353 | /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
354 | RTLOGFLAGS_REL_TS = 0x00000040,
|
---|
355 | /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
356 | RTLOGFLAGS_DECIMAL_TS = 0x00000080,
|
---|
357 | /** Open the file in write through mode. */
|
---|
358 | RTLOGFLAGS_WRITE_THROUGH = 0x00000100,
|
---|
359 | /** Flush the file to disk when flushing the buffer. */
|
---|
360 | RTLOGFLAGS_FLUSH = 0x00000200,
|
---|
361 | /** Restrict the number of log entries per group. */
|
---|
362 | RTLOGFLAGS_RESTRICT_GROUPS = 0x00000400,
|
---|
363 | /** New lines should be prefixed with the write and read lock counts. */
|
---|
364 | RTLOGFLAGS_PREFIX_LOCK_COUNTS = 0x00008000,
|
---|
365 | /** New lines should be prefixed with the CPU id (ApicID on intel/amd). */
|
---|
366 | RTLOGFLAGS_PREFIX_CPUID = 0x00010000,
|
---|
367 | /** New lines should be prefixed with the native process id. */
|
---|
368 | RTLOGFLAGS_PREFIX_PID = 0x00020000,
|
---|
369 | /** New lines should be prefixed with group flag number causing the output. */
|
---|
370 | RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,
|
---|
371 | /** New lines should be prefixed with group flag name causing the output. */
|
---|
372 | RTLOGFLAGS_PREFIX_FLAG = 0x00080000,
|
---|
373 | /** New lines should be prefixed with group number. */
|
---|
374 | RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,
|
---|
375 | /** New lines should be prefixed with group name. */
|
---|
376 | RTLOGFLAGS_PREFIX_GROUP = 0x00200000,
|
---|
377 | /** New lines should be prefixed with the native thread id. */
|
---|
378 | RTLOGFLAGS_PREFIX_TID = 0x00400000,
|
---|
379 | /** New lines should be prefixed with thread name. */
|
---|
380 | RTLOGFLAGS_PREFIX_THREAD = 0x00800000,
|
---|
381 | /** New lines should be prefixed with data from a custom callback. */
|
---|
382 | RTLOGFLAGS_PREFIX_CUSTOM = 0x01000000,
|
---|
383 | /** New lines should be prefixed with formatted timestamp since program start. */
|
---|
384 | RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
|
---|
385 | /** New lines should be prefixed with formatted timestamp (UCT). */
|
---|
386 | RTLOGFLAGS_PREFIX_TIME = 0x08000000,
|
---|
387 | /** New lines should be prefixed with milliseconds since program start. */
|
---|
388 | RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,
|
---|
389 | /** New lines should be prefixed with timestamp. */
|
---|
390 | RTLOGFLAGS_PREFIX_TSC = 0x20000000,
|
---|
391 | /** New lines should be prefixed with timestamp. */
|
---|
392 | RTLOGFLAGS_PREFIX_TS = 0x40000000,
|
---|
393 | /** The prefix mask. */
|
---|
394 | RTLOGFLAGS_PREFIX_MASK = 0x7dff8000
|
---|
395 | } RTLOGFLAGS;
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Logger per group flags.
|
---|
399 | */
|
---|
400 | typedef enum RTLOGGRPFLAGS
|
---|
401 | {
|
---|
402 | /** Enabled. */
|
---|
403 | RTLOGGRPFLAGS_ENABLED = 0x00000001,
|
---|
404 | /** Level 1 logging. */
|
---|
405 | RTLOGGRPFLAGS_LEVEL_1 = 0x00000002,
|
---|
406 | /** Level 2 logging. */
|
---|
407 | RTLOGGRPFLAGS_LEVEL_2 = 0x00000004,
|
---|
408 | /** Level 3 logging. */
|
---|
409 | RTLOGGRPFLAGS_LEVEL_3 = 0x00000008,
|
---|
410 | /** Level 4 logging. */
|
---|
411 | RTLOGGRPFLAGS_LEVEL_4 = 0x00000010,
|
---|
412 | /** Level 5 logging. */
|
---|
413 | RTLOGGRPFLAGS_LEVEL_5 = 0x00000020,
|
---|
414 | /** Level 6 logging. */
|
---|
415 | RTLOGGRPFLAGS_LEVEL_6 = 0x00000040,
|
---|
416 | /** Flow logging. */
|
---|
417 | RTLOGGRPFLAGS_FLOW = 0x00000080,
|
---|
418 | /** Restrict the number of log entries. */
|
---|
419 | RTLOGGRPFLAGS_RESTRICT = 0x00000100,
|
---|
420 |
|
---|
421 | /** Lelik logging. */
|
---|
422 | RTLOGGRPFLAGS_LELIK = 0x00010000,
|
---|
423 | /** Michael logging. */
|
---|
424 | RTLOGGRPFLAGS_MICHAEL = 0x00020000,
|
---|
425 | /** sunlover logging. */
|
---|
426 | RTLOGGRPFLAGS_SUNLOVER = 0x00040000,
|
---|
427 | /** Achim logging. */
|
---|
428 | RTLOGGRPFLAGS_ACHIM = 0x00080000,
|
---|
429 | /** Sander logging. */
|
---|
430 | RTLOGGRPFLAGS_SANDER = 0x00100000,
|
---|
431 | /** Klaus logging. */
|
---|
432 | RTLOGGRPFLAGS_KLAUS = 0x00200000,
|
---|
433 | /** Frank logging. */
|
---|
434 | RTLOGGRPFLAGS_FRANK = 0x00400000,
|
---|
435 | /** bird logging. */
|
---|
436 | RTLOGGRPFLAGS_BIRD = 0x00800000,
|
---|
437 | /** aleksey logging. */
|
---|
438 | RTLOGGRPFLAGS_ALEKSEY = 0x01000000,
|
---|
439 | /** dj logging. */
|
---|
440 | RTLOGGRPFLAGS_DJ = 0x02000000,
|
---|
441 | /** NoName logging. */
|
---|
442 | RTLOGGRPFLAGS_NONAME = 0x04000000
|
---|
443 | } RTLOGGRPFLAGS;
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Logger destination type.
|
---|
447 | */
|
---|
448 | typedef enum RTLOGDEST
|
---|
449 | {
|
---|
450 | /** Log to file. */
|
---|
451 | RTLOGDEST_FILE = 0x00000001,
|
---|
452 | /** Log to stdout. */
|
---|
453 | RTLOGDEST_STDOUT = 0x00000002,
|
---|
454 | /** Log to stderr. */
|
---|
455 | RTLOGDEST_STDERR = 0x00000004,
|
---|
456 | /** Log to debugger (win32 only). */
|
---|
457 | RTLOGDEST_DEBUGGER = 0x00000008,
|
---|
458 | /** Log to com port. */
|
---|
459 | RTLOGDEST_COM = 0x00000010,
|
---|
460 | /** Log a memory ring buffer. */
|
---|
461 | RTLOGDEST_RINGBUF = 0x00000020,
|
---|
462 | /** Just a dummy flag to be used when no other flag applies. */
|
---|
463 | RTLOGDEST_DUMMY = 0x20000000,
|
---|
464 | /** Log to a user defined output stream. */
|
---|
465 | RTLOGDEST_USER = 0x40000000
|
---|
466 | } RTLOGDEST;
|
---|
467 |
|
---|
468 |
|
---|
469 | RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
470 |
|
---|
471 |
|
---|
472 | #ifdef DOXYGEN_RUNNING
|
---|
473 | # define LOG_DISABLED
|
---|
474 | # define LOG_ENABLED
|
---|
475 | # define LOG_ENABLE_FLOW
|
---|
476 | #endif
|
---|
477 |
|
---|
478 | /** @def LOG_DISABLED
|
---|
479 | * Use this compile time define to disable all logging macros. It can
|
---|
480 | * be overridden for each of the logging macros by the LOG_ENABLE*
|
---|
481 | * compile time defines.
|
---|
482 | */
|
---|
483 |
|
---|
484 | /** @def LOG_ENABLED
|
---|
485 | * Use this compile time define to enable logging when not in debug mode
|
---|
486 | * or LOG_DISABLED is set.
|
---|
487 | * This will enabled Log() only.
|
---|
488 | */
|
---|
489 |
|
---|
490 | /** @def LOG_ENABLE_FLOW
|
---|
491 | * Use this compile time define to enable flow logging when not in
|
---|
492 | * debug mode or LOG_DISABLED is defined.
|
---|
493 | * This will enable LogFlow() only.
|
---|
494 | */
|
---|
495 |
|
---|
496 | /*
|
---|
497 | * Determine whether logging is enabled and forcefully normalize the indicators.
|
---|
498 | */
|
---|
499 | #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
|
---|
500 | # undef LOG_DISABLED
|
---|
501 | # undef LOG_ENABLED
|
---|
502 | # define LOG_ENABLED
|
---|
503 | #else
|
---|
504 | # undef LOG_ENABLED
|
---|
505 | # undef LOG_DISABLED
|
---|
506 | # define LOG_DISABLED
|
---|
507 | #endif
|
---|
508 |
|
---|
509 |
|
---|
510 | /** @def LOG_USE_C99
|
---|
511 | * Governs the use of variadic macros.
|
---|
512 | */
|
---|
513 | #ifndef LOG_USE_C99
|
---|
514 | # if defined(RT_ARCH_AMD64) || defined(RT_OS_DARWIN) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
|
---|
515 | # define LOG_USE_C99
|
---|
516 | # endif
|
---|
517 | #endif
|
---|
518 |
|
---|
519 |
|
---|
520 | /** @def LogIt
|
---|
521 | * Write to specific logger if group enabled.
|
---|
522 | */
|
---|
523 | #ifdef LOG_ENABLED
|
---|
524 | # if defined(LOG_USE_C99)
|
---|
525 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
526 | # define _LogIt(a_pvInst, a_fFlags, a_iGroup, ...) RTLogLoggerEx((PRTLOGGER)a_pvInst, a_fFlags, a_iGroup, __VA_ARGS__)
|
---|
527 | # define LogIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) _LogIt(a_pvInst, a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
|
---|
528 | # define _LogItAlways(a_pvInst, a_fFlags, a_iGroup, ...) RTLogLoggerEx((PRTLOGGER)a_pvInst, a_fFlags, ~0U, __VA_ARGS__)
|
---|
529 | # define LogItAlways(a_pvInst, a_fFlags, a_iGroup, fmtargs) _LogItAlways(a_pvInst, a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
|
---|
530 | /** @todo invent a flag or something for skipping the group check so we can pass iGroup. LogItAlways. */
|
---|
531 | # else
|
---|
532 | # define LogIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) \
|
---|
533 | do \
|
---|
534 | { \
|
---|
535 | register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogDefaultInstance(); \
|
---|
536 | if ( LogIt_pLogger \
|
---|
537 | && !(LogIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
538 | { \
|
---|
539 | register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(a_iGroup) < LogIt_pLogger->cGroups ? (unsigned)(a_iGroup) : 0]; \
|
---|
540 | if ((LogIt_fFlags & ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
541 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
542 | } \
|
---|
543 | } while (0)
|
---|
544 | # define LogItAlways(a_pvInst, a_fFlags, a_iGroup, fmtargs) \
|
---|
545 | do \
|
---|
546 | { \
|
---|
547 | register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogDefaultInstance(); \
|
---|
548 | if ( LogIt_pLogger \
|
---|
549 | && !(LogIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
550 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
551 | } while (0)
|
---|
552 | # endif
|
---|
553 | #else
|
---|
554 | # define LogIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
555 | # define LogItAlways(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
556 | # if defined(LOG_USE_C99)
|
---|
557 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
558 | # define _LogIt(a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
559 | # define _LogItAlways(a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
560 | # endif
|
---|
561 | #endif
|
---|
562 |
|
---|
563 |
|
---|
564 | /** @def Log
|
---|
565 | * Level 1 logging that works regardless of the group settings.
|
---|
566 | */
|
---|
567 | #define LogAlways(a) LogItAlways(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
568 |
|
---|
569 | /** @def Log
|
---|
570 | * Level 1 logging.
|
---|
571 | */
|
---|
572 | #define Log(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
573 |
|
---|
574 | /** @def Log2
|
---|
575 | * Level 2 logging.
|
---|
576 | */
|
---|
577 | #define Log2(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
578 |
|
---|
579 | /** @def Log3
|
---|
580 | * Level 3 logging.
|
---|
581 | */
|
---|
582 | #define Log3(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
583 |
|
---|
584 | /** @def Log4
|
---|
585 | * Level 4 logging.
|
---|
586 | */
|
---|
587 | #define Log4(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
588 |
|
---|
589 | /** @def Log5
|
---|
590 | * Level 5 logging.
|
---|
591 | */
|
---|
592 | #define Log5(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
593 |
|
---|
594 | /** @def Log6
|
---|
595 | * Level 6 logging.
|
---|
596 | */
|
---|
597 | #define Log6(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
598 |
|
---|
599 | /** @def LogFlow
|
---|
600 | * Logging of execution flow.
|
---|
601 | */
|
---|
602 | #define LogFlow(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
603 |
|
---|
604 | /** @def LogLelik
|
---|
605 | * lelik logging.
|
---|
606 | */
|
---|
607 | #define LogLelik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
608 |
|
---|
609 |
|
---|
610 | /** @def LogMichael
|
---|
611 | * michael logging.
|
---|
612 | */
|
---|
613 | #define LogMichael(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
614 |
|
---|
615 | /** @def LogSunlover
|
---|
616 | * sunlover logging.
|
---|
617 | */
|
---|
618 | #define LogSunlover(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
619 |
|
---|
620 | /** @def LogAchim
|
---|
621 | * Achim logging.
|
---|
622 | */
|
---|
623 | #define LogAchim(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
624 |
|
---|
625 | /** @def LogSander
|
---|
626 | * Sander logging.
|
---|
627 | */
|
---|
628 | #define LogSander(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
629 |
|
---|
630 | /** @def LogKlaus
|
---|
631 | * klaus logging.
|
---|
632 | */
|
---|
633 | #define LogKlaus(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
634 |
|
---|
635 | /** @def LogFrank
|
---|
636 | * frank logging.
|
---|
637 | */
|
---|
638 | #define LogFrank(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
639 |
|
---|
640 | /** @def LogBird
|
---|
641 | * bird logging.
|
---|
642 | */
|
---|
643 | #define LogBird(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
644 |
|
---|
645 | /** @def LogAleksey
|
---|
646 | * aleksey logging.
|
---|
647 | */
|
---|
648 | #define LogAleksey(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ALEKSEY, LOG_GROUP, a)
|
---|
649 |
|
---|
650 | /** @def LogDJ
|
---|
651 | * dj logging.
|
---|
652 | */
|
---|
653 | #define LogDJ(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_DJ, LOG_GROUP, a)
|
---|
654 |
|
---|
655 | /** @def LogNoName
|
---|
656 | * NoName logging.
|
---|
657 | */
|
---|
658 | #define LogNoName(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
659 |
|
---|
660 | /** @def LogWarning
|
---|
661 | * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
|
---|
662 | *
|
---|
663 | * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
|
---|
664 | */
|
---|
665 | #if defined(LOG_USE_C99)
|
---|
666 | # define LogWarning(a) \
|
---|
667 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a )
|
---|
668 | #else
|
---|
669 | # define LogWarning(a) \
|
---|
670 | do { Log(("WARNING! ")); Log(a); } while (0)
|
---|
671 | #endif
|
---|
672 |
|
---|
673 | /** @def LogTrace
|
---|
674 | * Macro to trace the execution flow: logs the file name, line number and
|
---|
675 | * function name. Can be easily searched for in log files using the
|
---|
676 | * ">>>>>" pattern (prepended to the beginning of each line).
|
---|
677 | */
|
---|
678 | #define LogTrace() \
|
---|
679 | LogFlow((">>>>> %s (%d): " LOG_FN_FMT "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__))
|
---|
680 |
|
---|
681 | /** @def LogTraceMsg
|
---|
682 | * The same as LogTrace but logs a custom log message right after the trace line.
|
---|
683 | *
|
---|
684 | * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
|
---|
685 | */
|
---|
686 | #ifdef LOG_USE_C99
|
---|
687 | # define LogTraceMsg(a) \
|
---|
688 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, ">>>>> %s (%d): " LOG_FN_FMT ": %M", __FILE__, __LINE__, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
689 | #else
|
---|
690 | # define LogTraceMsg(a) \
|
---|
691 | do { LogFlow((">>>>> %s (%d): " LOG_FN_FMT ": ", __FILE__, __LINE__, __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
692 | #endif
|
---|
693 |
|
---|
694 | /** @def LogFunc
|
---|
695 | * Level 1 logging inside C/C++ functions.
|
---|
696 | *
|
---|
697 | * Prepends the given log message with the function name followed by a
|
---|
698 | * semicolon and space.
|
---|
699 | *
|
---|
700 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
701 | */
|
---|
702 | #ifdef LOG_USE_C99
|
---|
703 | # define LogFunc(a) \
|
---|
704 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
705 | #else
|
---|
706 | # define LogFunc(a) \
|
---|
707 | do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
708 | #endif
|
---|
709 |
|
---|
710 | /** @def Log2Func
|
---|
711 | * Level 2 logging inside C/C++ functions.
|
---|
712 | *
|
---|
713 | * Prepends the given log message with the function name followed by a
|
---|
714 | * semicolon and space.
|
---|
715 | *
|
---|
716 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
717 | */
|
---|
718 | #ifdef LOG_USE_C99
|
---|
719 | # define Log2Func(a) \
|
---|
720 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
721 | #else
|
---|
722 | # define Log2Func(a) \
|
---|
723 | do { Log2((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log2(a); } while (0)
|
---|
724 | #endif
|
---|
725 |
|
---|
726 | /** @def Log3Func
|
---|
727 | * Level 3 logging inside C/C++ functions.
|
---|
728 | *
|
---|
729 | * Prepends the given log message with the function name followed by a
|
---|
730 | * semicolon and space.
|
---|
731 | *
|
---|
732 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
733 | */
|
---|
734 | #ifdef LOG_USE_C99
|
---|
735 | # define Log3Func(a) \
|
---|
736 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
737 | #else
|
---|
738 | # define Log3Func(a) \
|
---|
739 | do { Log3((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log3(a); } while (0)
|
---|
740 | #endif
|
---|
741 |
|
---|
742 | /** @def Log4Func
|
---|
743 | * Level 4 logging inside C/C++ functions.
|
---|
744 | *
|
---|
745 | * Prepends the given log message with the function name followed by a
|
---|
746 | * semicolon and space.
|
---|
747 | *
|
---|
748 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
749 | */
|
---|
750 | #ifdef LOG_USE_C99
|
---|
751 | # define Log4Func(a) \
|
---|
752 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
753 | #else
|
---|
754 | # define Log4Func(a) \
|
---|
755 | do { Log4((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log4(a); } while (0)
|
---|
756 | #endif
|
---|
757 |
|
---|
758 | /** @def Log5Func
|
---|
759 | * Level 5 logging inside C/C++ functions.
|
---|
760 | *
|
---|
761 | * Prepends the given log message with the function name followed by a
|
---|
762 | * semicolon and space.
|
---|
763 | *
|
---|
764 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
765 | */
|
---|
766 | #ifdef LOG_USE_C99
|
---|
767 | # define Log5Func(a) \
|
---|
768 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
769 | #else
|
---|
770 | # define Log5Func(a) \
|
---|
771 | do { Log5((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log5(a); } while (0)
|
---|
772 | #endif
|
---|
773 |
|
---|
774 | /** @def Log6Func
|
---|
775 | * Level 6 logging inside C/C++ functions.
|
---|
776 | *
|
---|
777 | * Prepends the given log message with the function name followed by a
|
---|
778 | * semicolon and space.
|
---|
779 | *
|
---|
780 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
781 | */
|
---|
782 | #ifdef LOG_USE_C99
|
---|
783 | # define Log6Func(a) \
|
---|
784 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
785 | #else
|
---|
786 | # define Log6Func(a) \
|
---|
787 | do { Log6((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log6(a); } while (0)
|
---|
788 | #endif
|
---|
789 |
|
---|
790 | /** @def LogThisFunc
|
---|
791 | * The same as LogFunc but for class functions (methods): the resulting log
|
---|
792 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
793 | *
|
---|
794 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
795 | */
|
---|
796 | #ifdef LOG_USE_C99
|
---|
797 | # define LogThisFunc(a) \
|
---|
798 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
799 | #else
|
---|
800 | # define LogThisFunc(a) \
|
---|
801 | do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
802 | #endif
|
---|
803 |
|
---|
804 | /** @def LogFlowFunc
|
---|
805 | * Macro to log the execution flow inside C/C++ functions.
|
---|
806 | *
|
---|
807 | * Prepends the given log message with the function name followed by
|
---|
808 | * a semicolon and space.
|
---|
809 | *
|
---|
810 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
811 | */
|
---|
812 | #ifdef LOG_USE_C99
|
---|
813 | # define LogFlowFunc(a) \
|
---|
814 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
815 | #else
|
---|
816 | # define LogFlowFunc(a) \
|
---|
817 | do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
818 | #endif
|
---|
819 |
|
---|
820 | /** @def LogWarningFunc
|
---|
821 | * The same as LogWarning(), but prepents the log message with the function name.
|
---|
822 | *
|
---|
823 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
824 | */
|
---|
825 | #ifdef LOG_USE_C99
|
---|
826 | # define LogWarningFunc(a) \
|
---|
827 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
828 | #else
|
---|
829 | # define LogWarningFunc(a) \
|
---|
830 | do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
831 | #endif
|
---|
832 |
|
---|
833 | /** @def LogFlowThisFunc
|
---|
834 | * The same as LogFlowFunc but for class functions (methods): the resulting log
|
---|
835 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
836 | *
|
---|
837 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
838 | */
|
---|
839 | #ifdef LOG_USE_C99
|
---|
840 | # define LogFlowThisFunc(a) \
|
---|
841 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
842 | #else
|
---|
843 | # define LogFlowThisFunc(a) \
|
---|
844 | do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
|
---|
845 | #endif
|
---|
846 |
|
---|
847 | /** @def LogWarningThisFunc
|
---|
848 | * The same as LogWarningFunc() but for class functions (methods): the resulting
|
---|
849 | * log line is additionally prepended with a hex value of |this| pointer.
|
---|
850 | *
|
---|
851 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
852 | */
|
---|
853 | #ifdef LOG_USE_C99
|
---|
854 | # define LogWarningThisFunc(a) \
|
---|
855 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
856 | #else
|
---|
857 | # define LogWarningThisFunc(a) \
|
---|
858 | do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
|
---|
859 | #endif
|
---|
860 |
|
---|
861 | /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
862 | #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
|
---|
863 |
|
---|
864 | /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
865 | #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
|
---|
866 |
|
---|
867 | /** Shortcut to |LogFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
|
---|
868 | #define LogFlowFuncLeaveRC(rc) LogFlowFunc(("LEAVE: %Rrc\n", (rc)))
|
---|
869 |
|
---|
870 | /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
|
---|
871 | #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
|
---|
872 |
|
---|
873 | /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
|
---|
874 | #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
|
---|
875 |
|
---|
876 | /** @def LogObjRefCnt
|
---|
877 | * Helper macro to print the current reference count of the given COM object
|
---|
878 | * to the log file.
|
---|
879 | *
|
---|
880 | * @param pObj Pointer to the object in question (must be a pointer to an
|
---|
881 | * IUnknown subclass or simply define COM-style AddRef() and
|
---|
882 | * Release() methods)
|
---|
883 | *
|
---|
884 | * @note Use it only for temporary debugging. It leaves dummy code even if
|
---|
885 | * logging is disabled.
|
---|
886 | */
|
---|
887 | #define LogObjRefCnt(pObj) \
|
---|
888 | do { \
|
---|
889 | int refc = (pObj)->AddRef(); \
|
---|
890 | LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), refc - 1)); \
|
---|
891 | (pObj)->Release(); \
|
---|
892 | } while (0)
|
---|
893 |
|
---|
894 |
|
---|
895 | /** @def LogIsItEnabled
|
---|
896 | * Checks whether the specified logging group is enabled or not.
|
---|
897 | */
|
---|
898 | #ifdef LOG_ENABLED
|
---|
899 | # define LogIsItEnabled(a_pvInst, a_fFlags, a_iGroup) \
|
---|
900 | LogIsItEnabledInternal((a_pvInst), (unsigned)(a_iGroup), (unsigned)(a_fFlags))
|
---|
901 | #else
|
---|
902 | # define LogIsItEnabled(a_pvInst, a_fFlags, a_iGroup) (false)
|
---|
903 | #endif
|
---|
904 |
|
---|
905 | /** @def LogIsEnabled
|
---|
906 | * Checks whether level 1 logging is enabled.
|
---|
907 | */
|
---|
908 | #define LogIsEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
909 |
|
---|
910 | /** @def LogIs2Enabled
|
---|
911 | * Checks whether level 2 logging is enabled.
|
---|
912 | */
|
---|
913 | #define LogIs2Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
914 |
|
---|
915 | /** @def LogIs3Enabled
|
---|
916 | * Checks whether level 3 logging is enabled.
|
---|
917 | */
|
---|
918 | #define LogIs3Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
919 |
|
---|
920 | /** @def LogIs4Enabled
|
---|
921 | * Checks whether level 4 logging is enabled.
|
---|
922 | */
|
---|
923 | #define LogIs4Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
924 |
|
---|
925 | /** @def LogIs5Enabled
|
---|
926 | * Checks whether level 5 logging is enabled.
|
---|
927 | */
|
---|
928 | #define LogIs5Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
929 |
|
---|
930 | /** @def LogIs6Enabled
|
---|
931 | * Checks whether level 6 logging is enabled.
|
---|
932 | */
|
---|
933 | #define LogIs6Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
934 |
|
---|
935 | /** @def LogIsFlowEnabled
|
---|
936 | * Checks whether execution flow logging is enabled.
|
---|
937 | */
|
---|
938 | #define LogIsFlowEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
939 |
|
---|
940 |
|
---|
941 | /** @name Passing Function Call Position When Logging.
|
---|
942 | *
|
---|
943 | * This is a little bit ugly as we have to omit the comma before the
|
---|
944 | * position parameters so that we don't inccur any overhead in non-logging
|
---|
945 | * builds (!defined(LOG_ENABLED).
|
---|
946 | *
|
---|
947 | * @{ */
|
---|
948 | /** Source position for passing to a function call. */
|
---|
949 | #ifdef LOG_ENABLED
|
---|
950 | # define RTLOG_COMMA_SRC_POS , __FILE__, __LINE__, __PRETTY_FUNCTION__
|
---|
951 | #else
|
---|
952 | # define RTLOG_COMMA_SRC_POS RT_NOTHING
|
---|
953 | #endif
|
---|
954 | /** Source position declaration. */
|
---|
955 | #ifdef LOG_ENABLED
|
---|
956 | # define RTLOG_COMMA_SRC_POS_DECL , const char *pszFile, unsigned iLine, const char *pszFunction
|
---|
957 | #else
|
---|
958 | # define RTLOG_COMMA_SRC_POS_DECL RT_NOTHING
|
---|
959 | #endif
|
---|
960 | /** Source position arguments. */
|
---|
961 | #ifdef LOG_ENABLED
|
---|
962 | # define RTLOG_COMMA_SRC_POS_ARGS , pszFile, iLine, pszFunction
|
---|
963 | #else
|
---|
964 | # define RTLOG_COMMA_SRC_POS_ARGS RT_NOTHING
|
---|
965 | #endif
|
---|
966 | /** Applies NOREF() to the source position arguments. */
|
---|
967 | #ifdef LOG_ENABLED
|
---|
968 | # define RTLOG_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
|
---|
969 | #else
|
---|
970 | # define RTLOG_SRC_POS_NOREF() do { } while (0)
|
---|
971 | #endif
|
---|
972 | /** @} */
|
---|
973 |
|
---|
974 |
|
---|
975 |
|
---|
976 | /** @name Release Logging
|
---|
977 | * @{
|
---|
978 | */
|
---|
979 |
|
---|
980 | #ifdef DOXYGEN_RUNNING
|
---|
981 | # define RTLOG_REL_DISABLED
|
---|
982 | # define RTLOG_REL_ENABLED
|
---|
983 | #endif
|
---|
984 |
|
---|
985 | /** @def RTLOG_REL_DISABLED
|
---|
986 | * Use this compile time define to disable all release logging
|
---|
987 | * macros.
|
---|
988 | */
|
---|
989 |
|
---|
990 | /** @def RTLOG_REL_ENABLED
|
---|
991 | * Use this compile time define to override RTLOG_REL_DISABLE.
|
---|
992 | */
|
---|
993 |
|
---|
994 | /*
|
---|
995 | * Determine whether release logging is enabled and forcefully normalize the indicators.
|
---|
996 | */
|
---|
997 | #if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED)
|
---|
998 | # undef RTLOG_REL_DISABLED
|
---|
999 | # undef RTLOG_REL_ENABLED
|
---|
1000 | # define RTLOG_REL_ENABLED
|
---|
1001 | #else
|
---|
1002 | # undef RTLOG_REL_ENABLED
|
---|
1003 | # undef RTLOG_REL_DISABLED
|
---|
1004 | # define RTLOG_REL_DISABLED
|
---|
1005 | #endif
|
---|
1006 |
|
---|
1007 |
|
---|
1008 | /** @def LogRelIt
|
---|
1009 | * Write to specific logger if group enabled.
|
---|
1010 | */
|
---|
1011 | /** @def LogRelMaxIt
|
---|
1012 | * Write to specific logger if group enabled and at less than a_cMax messages
|
---|
1013 | * have hit the log. Uses a static variable to count.
|
---|
1014 | */
|
---|
1015 | #ifdef RTLOG_REL_ENABLED
|
---|
1016 | # if defined(LOG_USE_C99)
|
---|
1017 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
1018 | # define _LogRelIt(a_pvInst, a_fFlags, a_iGroup, ...) \
|
---|
1019 | do \
|
---|
1020 | { \
|
---|
1021 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \
|
---|
1022 | if ( LogRelIt_pLogger \
|
---|
1023 | && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
1024 | RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1025 | _LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1026 | } while (0)
|
---|
1027 | # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) _LogRelIt(a_pvInst, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
|
---|
1028 | # define _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, ...) \
|
---|
1029 | do \
|
---|
1030 | { \
|
---|
1031 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \
|
---|
1032 | if ( LogRelIt_pLogger \
|
---|
1033 | && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
1034 | { \
|
---|
1035 | static uint32_t s_LogRelMaxIt_cLogged = 0; \
|
---|
1036 | if (s_LogRelMaxIt_cLogged < (a_cMax)) \
|
---|
1037 | { \
|
---|
1038 | s_LogRelMaxIt_cLogged++; \
|
---|
1039 | RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1040 | } \
|
---|
1041 | } \
|
---|
1042 | _LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, __VA_ARGS__); \
|
---|
1043 | } while (0)
|
---|
1044 | # define LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, fmtargs) \
|
---|
1045 | _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
|
---|
1046 | # else
|
---|
1047 | # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) \
|
---|
1048 | do \
|
---|
1049 | { \
|
---|
1050 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \
|
---|
1051 | if ( LogRelIt_pLogger \
|
---|
1052 | && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
1053 | { \
|
---|
1054 | unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(a_iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(a_iGroup) : 0]; \
|
---|
1055 | if ((LogIt_fFlags & ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
1056 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
1057 | } \
|
---|
1058 | LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, fmtargs); \
|
---|
1059 | } while (0)
|
---|
1060 | # define LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, fmtargs) \
|
---|
1061 | do \
|
---|
1062 | { \
|
---|
1063 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(a_pvInst) ? (PRTLOGGER)(a_pvInst) : RTLogRelDefaultInstance(); \
|
---|
1064 | if ( LogRelIt_pLogger \
|
---|
1065 | && !(LogRelIt_pLogger->fFlags & RTLOGFLAGS_DISABLED)) \
|
---|
1066 | { \
|
---|
1067 | unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(a_iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(a_iGroup) : 0]; \
|
---|
1068 | if ((LogIt_fFlags & ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((a_fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
1069 | { \
|
---|
1070 | static uint32_t s_LogRelMaxIt_cLogged = 0; \
|
---|
1071 | if (s_LogRelMaxIt_cLogged < (a_cMax)) \
|
---|
1072 | { \
|
---|
1073 | s_LogRelMaxIt_cLogged++; \
|
---|
1074 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
1075 | } \
|
---|
1076 | } \
|
---|
1077 | } \
|
---|
1078 | LogIt(LOG_INSTANCE, a_fFlags, a_iGroup, fmtargs); \
|
---|
1079 | } while (0)
|
---|
1080 | # endif
|
---|
1081 | #else /* !RTLOG_REL_ENABLED */
|
---|
1082 | # define LogRelIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
1083 | # define LogRelMaxIt(a_pvInst, a_fFlags, a_iGroup, fmtargs) do { } while (0)
|
---|
1084 | # if defined(LOG_USE_C99)
|
---|
1085 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
1086 | # define _LogRelIt(a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
1087 | # define _LogRelMaxIt(a_cMax, a_pvInst, a_fFlags, a_iGroup, ...) do { } while (0)
|
---|
1088 | # endif
|
---|
1089 | #endif /* !RTLOG_REL_ENABLED */
|
---|
1090 |
|
---|
1091 |
|
---|
1092 | /** @def LogRel
|
---|
1093 | * Level 1 logging.
|
---|
1094 | */
|
---|
1095 | #define LogRel(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
1096 |
|
---|
1097 | /** @def LogRel2
|
---|
1098 | * Level 2 logging.
|
---|
1099 | */
|
---|
1100 | #define LogRel2(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
1101 |
|
---|
1102 | /** @def LogRel3
|
---|
1103 | * Level 3 logging.
|
---|
1104 | */
|
---|
1105 | #define LogRel3(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
1106 |
|
---|
1107 | /** @def LogRel4
|
---|
1108 | * Level 4 logging.
|
---|
1109 | */
|
---|
1110 | #define LogRel4(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
1111 |
|
---|
1112 | /** @def LogRel5
|
---|
1113 | * Level 5 logging.
|
---|
1114 | */
|
---|
1115 | #define LogRel5(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
1116 |
|
---|
1117 | /** @def LogRel6
|
---|
1118 | * Level 6 logging.
|
---|
1119 | */
|
---|
1120 | #define LogRel6(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
1121 |
|
---|
1122 | /** @def LogRelFlow
|
---|
1123 | * Logging of execution flow.
|
---|
1124 | */
|
---|
1125 | #define LogRelFlow(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
1126 |
|
---|
1127 | /** @def LogRelFunc
|
---|
1128 | * Release logging. Prepends the given log message with the function name
|
---|
1129 | * followed by a semicolon and space.
|
---|
1130 | */
|
---|
1131 | #ifdef LOG_USE_C99
|
---|
1132 | # define LogRelFunc(a) \
|
---|
1133 | _LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1134 | # define LogFunc(a) \
|
---|
1135 | _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1136 | #else
|
---|
1137 | # define LogRelFunc(a) \
|
---|
1138 | do { LogRel((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
1139 | #endif
|
---|
1140 |
|
---|
1141 | /** @def LogRelThisFunc
|
---|
1142 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
1143 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
1144 | */
|
---|
1145 | #ifdef LOG_USE_C99
|
---|
1146 | # define LogRelThisFunc(a) \
|
---|
1147 | _LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1148 | #else
|
---|
1149 | # define LogRelThisFunc(a) \
|
---|
1150 | do { LogRel(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
1151 | #endif
|
---|
1152 |
|
---|
1153 | /** @def LogRelFlowFunc
|
---|
1154 | * Release logging. Macro to log the execution flow inside C/C++ functions.
|
---|
1155 | *
|
---|
1156 | * Prepends the given log message with the function name followed by
|
---|
1157 | * a semicolon and space.
|
---|
1158 | *
|
---|
1159 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1160 | */
|
---|
1161 | #ifdef LOG_USE_C99
|
---|
1162 | # define LogRelFlowFunc(a) \
|
---|
1163 | _LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1164 | #else
|
---|
1165 | # define LogRelFlowFunc(a) \
|
---|
1166 | do { LogRelFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
|
---|
1167 | #endif
|
---|
1168 |
|
---|
1169 | /** @def LogRelLelik
|
---|
1170 | * lelik logging.
|
---|
1171 | */
|
---|
1172 | #define LogRelLelik(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
1173 |
|
---|
1174 | /** @def LogRelMichael
|
---|
1175 | * michael logging.
|
---|
1176 | */
|
---|
1177 | #define LogRelMichael(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
1178 |
|
---|
1179 | /** @def LogRelSunlover
|
---|
1180 | * sunlover logging.
|
---|
1181 | */
|
---|
1182 | #define LogRelSunlover(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
1183 |
|
---|
1184 | /** @def LogRelAchim
|
---|
1185 | * Achim logging.
|
---|
1186 | */
|
---|
1187 | #define LogRelAchim(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
1188 |
|
---|
1189 | /** @def LogRelSander
|
---|
1190 | * Sander logging.
|
---|
1191 | */
|
---|
1192 | #define LogRelSander(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
1193 |
|
---|
1194 | /** @def LogRelKlaus
|
---|
1195 | * klaus logging.
|
---|
1196 | */
|
---|
1197 | #define LogRelKlaus(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
1198 |
|
---|
1199 | /** @def LogRelFrank
|
---|
1200 | * frank logging.
|
---|
1201 | */
|
---|
1202 | #define LogRelFrank(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
1203 |
|
---|
1204 | /** @def LogRelBird
|
---|
1205 | * bird logging.
|
---|
1206 | */
|
---|
1207 | #define LogRelBird(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
1208 |
|
---|
1209 | /** @def LogRelNoName
|
---|
1210 | * NoName logging.
|
---|
1211 | */
|
---|
1212 | #define LogRelNoName(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
1213 |
|
---|
1214 |
|
---|
1215 | /** @def LogRelMax
|
---|
1216 | * Level 1 logging.
|
---|
1217 | */
|
---|
1218 | #define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
1219 |
|
---|
1220 | /** @def LogRelMax2
|
---|
1221 | * Level 2 logging.
|
---|
1222 | */
|
---|
1223 | #define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
1224 |
|
---|
1225 | /** @def LogRelMax3
|
---|
1226 | * Level 3 logging.
|
---|
1227 | */
|
---|
1228 | #define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
1229 |
|
---|
1230 | /** @def LogRelMax4
|
---|
1231 | * Level 4 logging.
|
---|
1232 | */
|
---|
1233 | #define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
1234 |
|
---|
1235 | /** @def LogRelMax5
|
---|
1236 | * Level 5 logging.
|
---|
1237 | */
|
---|
1238 | #define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
1239 |
|
---|
1240 | /** @def LogRelMax6
|
---|
1241 | * Level 6 logging.
|
---|
1242 | */
|
---|
1243 | #define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
1244 |
|
---|
1245 | /** @def LogRelFlow
|
---|
1246 | * Logging of execution flow.
|
---|
1247 | */
|
---|
1248 | #define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
1249 |
|
---|
1250 | /** @def LogRelMaxFunc
|
---|
1251 | * Release logging. Prepends the given log message with the function name
|
---|
1252 | * followed by a semicolon and space.
|
---|
1253 | */
|
---|
1254 | #ifdef LOG_USE_C99
|
---|
1255 | # define LogRelMaxFunc(a_cMax, a) \
|
---|
1256 | _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", \
|
---|
1257 | __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1258 | # define LogFuncMax(a_cMax, a) \
|
---|
1259 | _LogItMax(a_cMax, LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", \
|
---|
1260 | __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1261 | #else
|
---|
1262 | # define LogRelMaxFunc(a_cMax, a) \
|
---|
1263 | do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
|
---|
1264 | #endif
|
---|
1265 |
|
---|
1266 | /** @def LogRelMaxThisFunc
|
---|
1267 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
1268 | * line is additionally prepended with a hex value of |this| pointer.
|
---|
1269 | * @param a_cMax Max number of times this should hit the log.
|
---|
1270 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1271 | */
|
---|
1272 | #ifdef LOG_USE_C99
|
---|
1273 | # define LogRelMaxThisFunc(a_cMax, a) \
|
---|
1274 | _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", \
|
---|
1275 | this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1276 | #else
|
---|
1277 | # define LogRelMaxThisFunc(a_cMax, a) \
|
---|
1278 | do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
|
---|
1279 | #endif
|
---|
1280 |
|
---|
1281 | /** @def LogRelMaxFlowFunc
|
---|
1282 | * Release logging. Macro to log the execution flow inside C/C++ functions.
|
---|
1283 | *
|
---|
1284 | * Prepends the given log message with the function name followed by
|
---|
1285 | * a semicolon and space.
|
---|
1286 | *
|
---|
1287 | * @param a_cMax Max number of times this should hit the log.
|
---|
1288 | * @param a Log message in format <tt>("string\n" [, args])</tt>.
|
---|
1289 | */
|
---|
1290 | #ifdef LOG_USE_C99
|
---|
1291 | # define LogRelMaxFlowFunc(a_cMax, a) \
|
---|
1292 | _LogRelMaxIt(a_cMax, LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", \
|
---|
1293 | __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
|
---|
1294 | #else
|
---|
1295 | # define LogRelMaxFlowFunc(a_cMax, a) \
|
---|
1296 | do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0)
|
---|
1297 | #endif
|
---|
1298 |
|
---|
1299 |
|
---|
1300 | /** @def LogRelIsItEnabled
|
---|
1301 | * Checks whether the specified logging group is enabled or not.
|
---|
1302 | */
|
---|
1303 | #define LogRelIsItEnabled(a_pvInst, a_fFlags, a_iGroup) \
|
---|
1304 | LogRelIsItEnabledInternal((a_pvInst), (unsigned)(a_iGroup), (unsigned)(a_fFlags))
|
---|
1305 |
|
---|
1306 | /** @def LogRelIsEnabled
|
---|
1307 | * Checks whether level 1 logging is enabled.
|
---|
1308 | */
|
---|
1309 | #define LogRelIsEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
1310 |
|
---|
1311 | /** @def LogRelIs2Enabled
|
---|
1312 | * Checks whether level 2 logging is enabled.
|
---|
1313 | */
|
---|
1314 | #define LogRelIs2Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
1315 |
|
---|
1316 | /** @def LogRelIs3Enabled
|
---|
1317 | * Checks whether level 3 logging is enabled.
|
---|
1318 | */
|
---|
1319 | #define LogRelIs3Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
1320 |
|
---|
1321 | /** @def LogRelIs4Enabled
|
---|
1322 | * Checks whether level 4 logging is enabled.
|
---|
1323 | */
|
---|
1324 | #define LogRelIs4Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
1325 |
|
---|
1326 | /** @def LogRelIs5Enabled
|
---|
1327 | * Checks whether level 5 logging is enabled.
|
---|
1328 | */
|
---|
1329 | #define LogRelIs5Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
1330 |
|
---|
1331 | /** @def LogRelIs6Enabled
|
---|
1332 | * Checks whether level 6 logging is enabled.
|
---|
1333 | */
|
---|
1334 | #define LogRelIs6Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
1335 |
|
---|
1336 | /** @def LogRelIsFlowEnabled
|
---|
1337 | * Checks whether execution flow logging is enabled.
|
---|
1338 | */
|
---|
1339 | #define LogRelIsFlowEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
1340 |
|
---|
1341 |
|
---|
1342 | #ifndef IN_RC
|
---|
1343 | /**
|
---|
1344 | * Sets the default release logger instance.
|
---|
1345 | *
|
---|
1346 | * @returns The old default instance.
|
---|
1347 | * @param pLogger The new default release logger instance.
|
---|
1348 | */
|
---|
1349 | RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger);
|
---|
1350 | #endif /* !IN_RC */
|
---|
1351 |
|
---|
1352 | /**
|
---|
1353 | * Gets the default release logger instance.
|
---|
1354 | *
|
---|
1355 | * @returns Pointer to default release logger instance.
|
---|
1356 | * @returns NULL if no default release logger instance available.
|
---|
1357 | */
|
---|
1358 | RTDECL(PRTLOGGER) RTLogRelDefaultInstance(void);
|
---|
1359 |
|
---|
1360 | /** Internal worker function.
|
---|
1361 | * Don't call directly, use the LogRelIsItEnabled macro!
|
---|
1362 | */
|
---|
1363 | DECLINLINE(bool) LogRelIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
1364 | {
|
---|
1365 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogRelDefaultInstance();
|
---|
1366 | if ( pLogger
|
---|
1367 | && !(pLogger->fFlags & RTLOGFLAGS_DISABLED))
|
---|
1368 | {
|
---|
1369 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
1370 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
1371 | return true;
|
---|
1372 | }
|
---|
1373 | return false;
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | /**
|
---|
1377 | * Write to a logger instance, defaulting to the release one.
|
---|
1378 | *
|
---|
1379 | * This function will check whether the instance, group and flags makes up a
|
---|
1380 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1381 | *
|
---|
1382 | * @param pLogger Pointer to logger instance.
|
---|
1383 | * @param fFlags The logging flags.
|
---|
1384 | * @param iGroup The group.
|
---|
1385 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1386 | * only for internal usage!
|
---|
1387 | * @param pszFormat Format string.
|
---|
1388 | * @param ... Format arguments.
|
---|
1389 | * @remark This is a worker function for LogRelIt.
|
---|
1390 | */
|
---|
1391 | RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
1392 |
|
---|
1393 | /**
|
---|
1394 | * Write to a logger instance, defaulting to the release one.
|
---|
1395 | *
|
---|
1396 | * This function will check whether the instance, group and flags makes up a
|
---|
1397 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1398 | *
|
---|
1399 | * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
|
---|
1400 | * @param fFlags The logging flags.
|
---|
1401 | * @param iGroup The group.
|
---|
1402 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1403 | * only for internal usage!
|
---|
1404 | * @param pszFormat Format string.
|
---|
1405 | * @param args Format arguments.
|
---|
1406 | */
|
---|
1407 | RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
1408 |
|
---|
1409 | /**
|
---|
1410 | * printf like function for writing to the default release log.
|
---|
1411 | *
|
---|
1412 | * @param pszFormat Printf like format string.
|
---|
1413 | * @param ... Optional arguments as specified in pszFormat.
|
---|
1414 | *
|
---|
1415 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1416 | */
|
---|
1417 | RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...);
|
---|
1418 |
|
---|
1419 | /**
|
---|
1420 | * vprintf like function for writing to the default release log.
|
---|
1421 | *
|
---|
1422 | * @param pszFormat Printf like format string.
|
---|
1423 | * @param args Optional arguments as specified in pszFormat.
|
---|
1424 | *
|
---|
1425 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1426 | */
|
---|
1427 | RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args);
|
---|
1428 |
|
---|
1429 | /**
|
---|
1430 | * Changes the buffering setting of the default release logger.
|
---|
1431 | *
|
---|
1432 | * This can be used for optimizing longish logging sequences.
|
---|
1433 | *
|
---|
1434 | * @returns The old state.
|
---|
1435 | * @param fBuffered The new state.
|
---|
1436 | */
|
---|
1437 | RTDECL(bool) RTLogRelSetBuffering(bool fBuffered);
|
---|
1438 |
|
---|
1439 | /** @} */
|
---|
1440 |
|
---|
1441 |
|
---|
1442 |
|
---|
1443 | /** @name COM port logging
|
---|
1444 | * {
|
---|
1445 | */
|
---|
1446 |
|
---|
1447 | #ifdef DOXYGEN_RUNNING
|
---|
1448 | # define LOG_TO_COM
|
---|
1449 | # define LOG_NO_COM
|
---|
1450 | #endif
|
---|
1451 |
|
---|
1452 | /** @def LOG_TO_COM
|
---|
1453 | * Redirects the normal logging macros to the serial versions.
|
---|
1454 | */
|
---|
1455 |
|
---|
1456 | /** @def LOG_NO_COM
|
---|
1457 | * Disables all LogCom* macros.
|
---|
1458 | */
|
---|
1459 |
|
---|
1460 | /** @def LogCom
|
---|
1461 | * Generic logging to serial port.
|
---|
1462 | */
|
---|
1463 | #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
|
---|
1464 | # define LogCom(a) RTLogComPrintf a
|
---|
1465 | #else
|
---|
1466 | # define LogCom(a) do { } while (0)
|
---|
1467 | #endif
|
---|
1468 |
|
---|
1469 | /** @def LogComFlow
|
---|
1470 | * Logging to serial port of execution flow.
|
---|
1471 | */
|
---|
1472 | #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
|
---|
1473 | # define LogComFlow(a) RTLogComPrintf a
|
---|
1474 | #else
|
---|
1475 | # define LogComFlow(a) do { } while (0)
|
---|
1476 | #endif
|
---|
1477 |
|
---|
1478 | #ifdef LOG_TO_COM
|
---|
1479 | # undef Log
|
---|
1480 | # define Log(a) LogCom(a)
|
---|
1481 | # undef LogFlow
|
---|
1482 | # define LogFlow(a) LogComFlow(a)
|
---|
1483 | #endif
|
---|
1484 |
|
---|
1485 | /** @} */
|
---|
1486 |
|
---|
1487 |
|
---|
1488 | /** @name Backdoor Logging
|
---|
1489 | * @{
|
---|
1490 | */
|
---|
1491 |
|
---|
1492 | #ifdef DOXYGEN_RUNNING
|
---|
1493 | # define LOG_TO_BACKDOOR
|
---|
1494 | # define LOG_NO_BACKDOOR
|
---|
1495 | #endif
|
---|
1496 |
|
---|
1497 | /** @def LOG_TO_BACKDOOR
|
---|
1498 | * Redirects the normal logging macros to the backdoor versions.
|
---|
1499 | */
|
---|
1500 |
|
---|
1501 | /** @def LOG_NO_BACKDOOR
|
---|
1502 | * Disables all LogBackdoor* macros.
|
---|
1503 | */
|
---|
1504 |
|
---|
1505 | /** @def LogBackdoor
|
---|
1506 | * Generic logging to the VBox backdoor via port I/O.
|
---|
1507 | */
|
---|
1508 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
1509 | # define LogBackdoor(a) RTLogBackdoorPrintf a
|
---|
1510 | #else
|
---|
1511 | # define LogBackdoor(a) do { } while (0)
|
---|
1512 | #endif
|
---|
1513 |
|
---|
1514 | /** @def LogBackdoorFlow
|
---|
1515 | * Logging of execution flow messages to the backdoor I/O port.
|
---|
1516 | */
|
---|
1517 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
1518 | # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
|
---|
1519 | #else
|
---|
1520 | # define LogBackdoorFlow(a) do { } while (0)
|
---|
1521 | #endif
|
---|
1522 |
|
---|
1523 | /** @def LogRelBackdoor
|
---|
1524 | * Release logging to the VBox backdoor via port I/O.
|
---|
1525 | */
|
---|
1526 | #if !defined(LOG_NO_BACKDOOR)
|
---|
1527 | # define LogRelBackdoor(a) RTLogBackdoorPrintf a
|
---|
1528 | #else
|
---|
1529 | # define LogRelBackdoor(a) do { } while (0)
|
---|
1530 | #endif
|
---|
1531 |
|
---|
1532 | #ifdef LOG_TO_BACKDOOR
|
---|
1533 | # undef Log
|
---|
1534 | # define Log(a) LogBackdoor(a)
|
---|
1535 | # undef LogFlow
|
---|
1536 | # define LogFlow(a) LogBackdoorFlow(a)
|
---|
1537 | # undef LogRel
|
---|
1538 | # define LogRel(a) LogRelBackdoor(a)
|
---|
1539 | # if defined(LOG_USE_C99)
|
---|
1540 | # undef _LogIt
|
---|
1541 | # define _LogIt(a_pvInst, a_fFlags, a_iGroup, ...) LogBackdoor((__VA_ARGS__))
|
---|
1542 | # endif
|
---|
1543 | #endif
|
---|
1544 |
|
---|
1545 | /** @} */
|
---|
1546 |
|
---|
1547 |
|
---|
1548 |
|
---|
1549 | /**
|
---|
1550 | * Gets the default logger instance, creating it if necessary.
|
---|
1551 | *
|
---|
1552 | * @returns Pointer to default logger instance.
|
---|
1553 | * @returns NULL if no default logger instance available.
|
---|
1554 | */
|
---|
1555 | RTDECL(PRTLOGGER) RTLogDefaultInstance(void);
|
---|
1556 |
|
---|
1557 | /**
|
---|
1558 | * Gets the default logger instance.
|
---|
1559 | *
|
---|
1560 | * @returns Pointer to default logger instance.
|
---|
1561 | * @returns NULL if no default logger instance available.
|
---|
1562 | */
|
---|
1563 | RTDECL(PRTLOGGER) RTLogGetDefaultInstance(void);
|
---|
1564 |
|
---|
1565 | #ifndef IN_RC
|
---|
1566 | /**
|
---|
1567 | * Sets the default logger instance.
|
---|
1568 | *
|
---|
1569 | * @returns The old default instance.
|
---|
1570 | * @param pLogger The new default logger instance.
|
---|
1571 | */
|
---|
1572 | RTDECL(PRTLOGGER) RTLogSetDefaultInstance(PRTLOGGER pLogger);
|
---|
1573 | #endif /* !IN_RC */
|
---|
1574 |
|
---|
1575 | #ifdef IN_RING0
|
---|
1576 | /**
|
---|
1577 | * Changes the default logger instance for the current thread.
|
---|
1578 | *
|
---|
1579 | * @returns IPRT status code.
|
---|
1580 | * @param pLogger The logger instance. Pass NULL for deregistration.
|
---|
1581 | * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
|
---|
1582 | * all instances with this key will be deregistered. So in
|
---|
1583 | * order to only deregister the instance associated with the
|
---|
1584 | * current thread use 0.
|
---|
1585 | */
|
---|
1586 | RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
|
---|
1587 | #endif /* IN_RING0 */
|
---|
1588 |
|
---|
1589 |
|
---|
1590 | #ifdef LOG_ENABLED
|
---|
1591 | /** Internal worker function.
|
---|
1592 | * Don't call directly, use the LogIsItEnabled macro!
|
---|
1593 | */
|
---|
1594 | DECLINLINE(bool) LogIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
1595 | {
|
---|
1596 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogDefaultInstance();
|
---|
1597 | if ( pLogger
|
---|
1598 | && !(pLogger->fFlags & RTLOGFLAGS_DISABLED))
|
---|
1599 | {
|
---|
1600 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
1601 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
1602 | return true;
|
---|
1603 | }
|
---|
1604 | return false;
|
---|
1605 | }
|
---|
1606 | #endif
|
---|
1607 |
|
---|
1608 |
|
---|
1609 | #ifndef IN_RC
|
---|
1610 | /**
|
---|
1611 | * Creates the default logger instance for a iprt users.
|
---|
1612 | *
|
---|
1613 | * Any user of the logging features will need to implement
|
---|
1614 | * this or use the generic dummy.
|
---|
1615 | *
|
---|
1616 | * @returns Pointer to the logger instance.
|
---|
1617 | */
|
---|
1618 | RTDECL(PRTLOGGER) RTLogDefaultInit(void);
|
---|
1619 |
|
---|
1620 | /**
|
---|
1621 | * Create a logger instance.
|
---|
1622 | *
|
---|
1623 | * @returns iprt status code.
|
---|
1624 | *
|
---|
1625 | * @param ppLogger Where to store the logger instance.
|
---|
1626 | * @param fFlags Logger instance flags, a combination of the
|
---|
1627 | * RTLOGFLAGS_* values.
|
---|
1628 | * @param pszGroupSettings The initial group settings.
|
---|
1629 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
1630 | * this instance.
|
---|
1631 | * @param cGroups Number of groups in the array.
|
---|
1632 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
1633 | * around for the life of the logger instance.
|
---|
1634 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
1635 | * if pszFilenameFmt specified.
|
---|
1636 | * @param pszFilenameFmt Log filename format string. Standard
|
---|
1637 | * RTStrFormat().
|
---|
1638 | * @param ... Format arguments.
|
---|
1639 | */
|
---|
1640 | RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
|
---|
1641 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1642 | uint32_t fDestFlags, const char *pszFilenameFmt, ...);
|
---|
1643 |
|
---|
1644 | /**
|
---|
1645 | * Create a logger instance.
|
---|
1646 | *
|
---|
1647 | * @returns iprt status code.
|
---|
1648 | *
|
---|
1649 | * @param ppLogger Where to store the logger instance.
|
---|
1650 | * @param fFlags Logger instance flags, a combination of the
|
---|
1651 | * RTLOGFLAGS_* values.
|
---|
1652 | * @param pszGroupSettings The initial group settings.
|
---|
1653 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
1654 | * this instance.
|
---|
1655 | * @param cGroups Number of groups in the array.
|
---|
1656 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
1657 | * around for the life of the logger instance.
|
---|
1658 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
1659 | * if pszFilenameFmt specified.
|
---|
1660 | * @param pfnPhase Callback function for starting logging and for
|
---|
1661 | * ending or starting a new file for log history
|
---|
1662 | * rotation. NULL is OK.
|
---|
1663 | * @param cHistory Number of old log files to keep when performing
|
---|
1664 | * log history rotation. 0 means no history.
|
---|
1665 | * @param cbHistoryFileMax Maximum size of log file when performing
|
---|
1666 | * history rotation. 0 means no size limit.
|
---|
1667 | * @param cSecsHistoryTimeSlot Maximum time interval per log file when
|
---|
1668 | * performing history rotation, in seconds.
|
---|
1669 | * 0 means time limit.
|
---|
1670 | * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
|
---|
1671 | * @param cchErrorMsg The size of the error message buffer.
|
---|
1672 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
1673 | * @param ... Format arguments.
|
---|
1674 | */
|
---|
1675 | RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
|
---|
1676 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1677 | uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
|
---|
1678 | uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
|
---|
1679 | char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
|
---|
1680 |
|
---|
1681 | /**
|
---|
1682 | * Create a logger instance.
|
---|
1683 | *
|
---|
1684 | * @returns iprt status code.
|
---|
1685 | *
|
---|
1686 | * @param ppLogger Where to store the logger instance.
|
---|
1687 | * @param fFlags Logger instance flags, a combination of the
|
---|
1688 | * RTLOGFLAGS_* values.
|
---|
1689 | * @param pszGroupSettings The initial group settings.
|
---|
1690 | * @param pszEnvVarBase Base name for the environment variables for
|
---|
1691 | * this instance.
|
---|
1692 | * @param cGroups Number of groups in the array.
|
---|
1693 | * @param papszGroups Pointer to array of groups. This must stick
|
---|
1694 | * around for the life of the logger instance.
|
---|
1695 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
|
---|
1696 | * if pszFilenameFmt specified.
|
---|
1697 | * @param pfnPhase Callback function for starting logging and for
|
---|
1698 | * ending or starting a new file for log history
|
---|
1699 | * rotation.
|
---|
1700 | * @param cHistory Number of old log files to keep when performing
|
---|
1701 | * log history rotation. 0 means no history.
|
---|
1702 | * @param cbHistoryFileMax Maximum size of log file when performing
|
---|
1703 | * history rotation. 0 means no size limit.
|
---|
1704 | * @param cSecsHistoryTimeSlot Maximum time interval per log file when
|
---|
1705 | * performing history rotation, in seconds.
|
---|
1706 | * 0 means no time limit.
|
---|
1707 | * @param pszErrorMsg A buffer which is filled with an error message
|
---|
1708 | * if something fails. May be NULL.
|
---|
1709 | * @param cchErrorMsg The size of the error message buffer.
|
---|
1710 | * @param pszFilenameFmt Log filename format string. Standard
|
---|
1711 | * RTStrFormat().
|
---|
1712 | * @param args Format arguments.
|
---|
1713 | */
|
---|
1714 | RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, uint32_t fFlags, const char *pszGroupSettings,
|
---|
1715 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1716 | uint32_t fDestFlags, PFNRTLOGPHASE pfnPhase, uint32_t cHistory,
|
---|
1717 | uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
|
---|
1718 | char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
|
---|
1719 |
|
---|
1720 | /**
|
---|
1721 | * Create a logger instance for singled threaded ring-0 usage.
|
---|
1722 | *
|
---|
1723 | * @returns iprt status code.
|
---|
1724 | *
|
---|
1725 | * @param pLogger Where to create the logger instance.
|
---|
1726 | * @param cbLogger The amount of memory available for the logger instance.
|
---|
1727 | * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
|
---|
1728 | * @param pfnLoggerR0Ptr Pointer to logger wrapper function.
|
---|
1729 | * @param pfnFlushR0Ptr Pointer to flush function.
|
---|
1730 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1731 | * @param fDestFlags The destination flags.
|
---|
1732 | */
|
---|
1733 | RTDECL(int) RTLogCreateForR0(PRTLOGGER pLogger, size_t cbLogger,
|
---|
1734 | RTR0PTR pLoggerR0Ptr, RTR0PTR pfnLoggerR0Ptr, RTR0PTR pfnFlushR0Ptr,
|
---|
1735 | uint32_t fFlags, uint32_t fDestFlags);
|
---|
1736 |
|
---|
1737 | /**
|
---|
1738 | * Calculates the minimum size of a ring-0 logger instance.
|
---|
1739 | *
|
---|
1740 | * @returns The minimum size.
|
---|
1741 | * @param cGroups The number of groups.
|
---|
1742 | * @param fFlags Relevant flags.
|
---|
1743 | */
|
---|
1744 | RTDECL(size_t) RTLogCalcSizeForR0(uint32_t cGroups, uint32_t fFlags);
|
---|
1745 |
|
---|
1746 | /**
|
---|
1747 | * Destroys a logger instance.
|
---|
1748 | *
|
---|
1749 | * The instance is flushed and all output destinations closed (where applicable).
|
---|
1750 | *
|
---|
1751 | * @returns iprt status code.
|
---|
1752 | * @param pLogger The logger instance which close destroyed. NULL is fine.
|
---|
1753 | */
|
---|
1754 | RTDECL(int) RTLogDestroy(PRTLOGGER pLogger);
|
---|
1755 |
|
---|
1756 | /**
|
---|
1757 | * Create a logger instance clone for RC usage.
|
---|
1758 | *
|
---|
1759 | * @returns iprt status code.
|
---|
1760 | *
|
---|
1761 | * @param pLogger The logger instance to be cloned.
|
---|
1762 | * @param pLoggerRC Where to create the RC logger instance.
|
---|
1763 | * @param cbLoggerRC Amount of memory allocated to for the RC logger
|
---|
1764 | * instance clone.
|
---|
1765 | * @param pfnLoggerRCPtr Pointer to logger wrapper function for this
|
---|
1766 | * instance (RC Ptr).
|
---|
1767 | * @param pfnFlushRCPtr Pointer to flush function (RC Ptr).
|
---|
1768 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1769 | */
|
---|
1770 | RTDECL(int) RTLogCloneRC(PRTLOGGER pLogger, PRTLOGGERRC pLoggerRC, size_t cbLoggerRC,
|
---|
1771 | RTRCPTR pfnLoggerRCPtr, RTRCPTR pfnFlushRCPtr, uint32_t fFlags);
|
---|
1772 |
|
---|
1773 | /**
|
---|
1774 | * Flushes a RC logger instance to a R3 logger.
|
---|
1775 | *
|
---|
1776 | * @returns iprt status code.
|
---|
1777 | * @param pLogger The R3 logger instance to flush pLoggerRC to. If NULL
|
---|
1778 | * the default logger is used.
|
---|
1779 | * @param pLoggerRC The RC logger instance to flush.
|
---|
1780 | */
|
---|
1781 | RTDECL(void) RTLogFlushRC(PRTLOGGER pLogger, PRTLOGGERRC pLoggerRC);
|
---|
1782 |
|
---|
1783 | /**
|
---|
1784 | * Flushes the buffer in one logger instance onto another logger.
|
---|
1785 | *
|
---|
1786 | * @returns iprt status code.
|
---|
1787 | *
|
---|
1788 | * @param pSrcLogger The logger instance to flush.
|
---|
1789 | * @param pDstLogger The logger instance to flush onto.
|
---|
1790 | * If NULL the default logger will be used.
|
---|
1791 | */
|
---|
1792 | RTDECL(void) RTLogFlushToLogger(PRTLOGGER pSrcLogger, PRTLOGGER pDstLogger);
|
---|
1793 |
|
---|
1794 | /**
|
---|
1795 | * Flushes a R0 logger instance to a R3 logger.
|
---|
1796 | *
|
---|
1797 | * @returns iprt status code.
|
---|
1798 | * @param pLogger The R3 logger instance to flush pLoggerR0 to. If NULL
|
---|
1799 | * the default logger is used.
|
---|
1800 | * @param pLoggerR0 The R0 logger instance to flush.
|
---|
1801 | */
|
---|
1802 | RTDECL(void) RTLogFlushR0(PRTLOGGER pLogger, PRTLOGGER pLoggerR0);
|
---|
1803 |
|
---|
1804 | /**
|
---|
1805 | * Sets the custom prefix callback.
|
---|
1806 | *
|
---|
1807 | * @returns IPRT status code.
|
---|
1808 | * @param pLogger The logger instance.
|
---|
1809 | * @param pfnCallback The callback.
|
---|
1810 | * @param pvUser The user argument for the callback.
|
---|
1811 | * */
|
---|
1812 | RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger, PFNRTLOGPREFIX pfnCallback, void *pvUser);
|
---|
1813 |
|
---|
1814 | /**
|
---|
1815 | * Same as RTLogSetCustomPrefixCallback for loggers created by
|
---|
1816 | * RTLogCreateForR0.
|
---|
1817 | *
|
---|
1818 | * @returns IPRT status code.
|
---|
1819 | * @param pLogger The logger instance.
|
---|
1820 | * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
|
---|
1821 | * @param pfnCallbackR0Ptr The callback.
|
---|
1822 | * @param pvUserR0Ptr The user argument for the callback.
|
---|
1823 | * */
|
---|
1824 | RTDECL(int) RTLogSetCustomPrefixCallbackForR0(PRTLOGGER pLogger, RTR0PTR pLoggerR0Ptr,
|
---|
1825 | RTR0PTR pfnCallbackR0Ptr, RTR0PTR pvUserR0Ptr);
|
---|
1826 |
|
---|
1827 | /**
|
---|
1828 | * Copies the group settings and flags from logger instance to another.
|
---|
1829 | *
|
---|
1830 | * @returns IPRT status code.
|
---|
1831 | * @param pDstLogger The destination logger instance.
|
---|
1832 | * @param pDstLoggerR0Ptr The ring-0 address corresponding to @a pDstLogger.
|
---|
1833 | * @param pSrcLogger The source logger instance. If NULL the default one is used.
|
---|
1834 | * @param fFlagsOr OR mask for the flags.
|
---|
1835 | * @param fFlagsAnd AND mask for the flags.
|
---|
1836 | */
|
---|
1837 | RTDECL(int) RTLogCopyGroupsAndFlagsForR0(PRTLOGGER pDstLogger, RTR0PTR pDstLoggerR0Ptr,
|
---|
1838 | PCRTLOGGER pSrcLogger, uint32_t fFlagsOr, uint32_t fFlagsAnd);
|
---|
1839 |
|
---|
1840 | /**
|
---|
1841 | * Get the current log group settings as a string.
|
---|
1842 | *
|
---|
1843 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
1844 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1845 | * @param pszBuf The output buffer.
|
---|
1846 | * @param cchBuf The size of the output buffer. Must be greater
|
---|
1847 | * than zero.
|
---|
1848 | */
|
---|
1849 | RTDECL(int) RTLogGetGroupSettings(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
1850 |
|
---|
1851 | /**
|
---|
1852 | * Updates the group settings for the logger instance using the specified
|
---|
1853 | * specification string.
|
---|
1854 | *
|
---|
1855 | * @returns iprt status code.
|
---|
1856 | * Failures can safely be ignored.
|
---|
1857 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1858 | * @param pszValue Value to parse.
|
---|
1859 | */
|
---|
1860 | RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger, const char *pszValue);
|
---|
1861 | #endif /* !IN_RC */
|
---|
1862 |
|
---|
1863 | /**
|
---|
1864 | * Updates the flags for the logger instance using the specified
|
---|
1865 | * specification string.
|
---|
1866 | *
|
---|
1867 | * @returns iprt status code.
|
---|
1868 | * Failures can safely be ignored.
|
---|
1869 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1870 | * @param pszValue Value to parse.
|
---|
1871 | */
|
---|
1872 | RTDECL(int) RTLogFlags(PRTLOGGER pLogger, const char *pszValue);
|
---|
1873 |
|
---|
1874 | /**
|
---|
1875 | * Changes the buffering setting of the specified logger.
|
---|
1876 | *
|
---|
1877 | * This can be used for optimizing longish logging sequences.
|
---|
1878 | *
|
---|
1879 | * @returns The old state.
|
---|
1880 | * @param pLogger The logger instance (NULL is an alias for the
|
---|
1881 | * default logger).
|
---|
1882 | * @param fBuffered The new state.
|
---|
1883 | */
|
---|
1884 | RTDECL(bool) RTLogSetBuffering(PRTLOGGER pLogger, bool fBuffered);
|
---|
1885 |
|
---|
1886 | /**
|
---|
1887 | * Sets the max number of entries per group.
|
---|
1888 | *
|
---|
1889 | * @returns Old restriction.
|
---|
1890 | *
|
---|
1891 | * @param pLogger The logger instance (NULL is an alias for the
|
---|
1892 | * default logger).
|
---|
1893 | * @param cMaxEntriesPerGroup The max number of entries per group.
|
---|
1894 | *
|
---|
1895 | * @remarks Lowering the limit of an active logger may quietly mute groups.
|
---|
1896 | * Raising it may reactive already muted groups.
|
---|
1897 | */
|
---|
1898 | RTDECL(uint32_t) RTLogSetGroupLimit(PRTLOGGER pLogger, uint32_t cMaxEntriesPerGroup);
|
---|
1899 |
|
---|
1900 | #ifndef IN_RC
|
---|
1901 | /**
|
---|
1902 | * Get the current log flags as a string.
|
---|
1903 | *
|
---|
1904 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
1905 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1906 | * @param pszBuf The output buffer.
|
---|
1907 | * @param cchBuf The size of the output buffer. Must be greater
|
---|
1908 | * than zero.
|
---|
1909 | */
|
---|
1910 | RTDECL(int) RTLogGetFlags(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
1911 |
|
---|
1912 | /**
|
---|
1913 | * Updates the logger destination using the specified string.
|
---|
1914 | *
|
---|
1915 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
1916 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1917 | * @param pszValue The value to parse.
|
---|
1918 | */
|
---|
1919 | RTDECL(int) RTLogDestinations(PRTLOGGER pLogger, char const *pszValue);
|
---|
1920 |
|
---|
1921 | /**
|
---|
1922 | * Get the current log destinations as a string.
|
---|
1923 | *
|
---|
1924 | * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
|
---|
1925 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1926 | * @param pszBuf The output buffer.
|
---|
1927 | * @param cchBuf The size of the output buffer. Must be greater
|
---|
1928 | * than 0.
|
---|
1929 | */
|
---|
1930 | RTDECL(int) RTLogGetDestinations(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
|
---|
1931 | #endif /* !IN_RC */
|
---|
1932 |
|
---|
1933 | /**
|
---|
1934 | * Flushes the specified logger.
|
---|
1935 | *
|
---|
1936 | * @param pLogger The logger instance to flush.
|
---|
1937 | * If NULL the default instance is used. The default instance
|
---|
1938 | * will not be initialized by this call.
|
---|
1939 | */
|
---|
1940 | RTDECL(void) RTLogFlush(PRTLOGGER pLogger);
|
---|
1941 |
|
---|
1942 | /**
|
---|
1943 | * Write to a logger instance.
|
---|
1944 | *
|
---|
1945 | * @param pLogger Pointer to logger instance.
|
---|
1946 | * @param pvCallerRet Ignored.
|
---|
1947 | * @param pszFormat Format string.
|
---|
1948 | * @param ... Format arguments.
|
---|
1949 | */
|
---|
1950 | RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...);
|
---|
1951 |
|
---|
1952 | /**
|
---|
1953 | * Write to a logger instance.
|
---|
1954 | *
|
---|
1955 | * @param pLogger Pointer to logger instance.
|
---|
1956 | * @param pszFormat Format string.
|
---|
1957 | * @param args Format arguments.
|
---|
1958 | */
|
---|
1959 | RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args);
|
---|
1960 |
|
---|
1961 | /**
|
---|
1962 | * Write to a logger instance.
|
---|
1963 | *
|
---|
1964 | * This function will check whether the instance, group and flags makes up a
|
---|
1965 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1966 | *
|
---|
1967 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
1968 | * @param fFlags The logging flags.
|
---|
1969 | * @param iGroup The group.
|
---|
1970 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1971 | * only for internal usage!
|
---|
1972 | * @param pszFormat Format string.
|
---|
1973 | * @param ... Format arguments.
|
---|
1974 | * @remark This is a worker function of LogIt.
|
---|
1975 | */
|
---|
1976 | RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
1977 |
|
---|
1978 | /**
|
---|
1979 | * Write to a logger instance.
|
---|
1980 | *
|
---|
1981 | * This function will check whether the instance, group and flags makes up a
|
---|
1982 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1983 | *
|
---|
1984 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
1985 | * @param fFlags The logging flags.
|
---|
1986 | * @param iGroup The group.
|
---|
1987 | * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
|
---|
1988 | * only for internal usage!
|
---|
1989 | * @param pszFormat Format string.
|
---|
1990 | * @param args Format arguments.
|
---|
1991 | */
|
---|
1992 | RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
1993 |
|
---|
1994 | /**
|
---|
1995 | * printf like function for writing to the default log.
|
---|
1996 | *
|
---|
1997 | * @param pszFormat Printf like format string.
|
---|
1998 | * @param ... Optional arguments as specified in pszFormat.
|
---|
1999 | *
|
---|
2000 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
2001 | */
|
---|
2002 | RTDECL(void) RTLogPrintf(const char *pszFormat, ...);
|
---|
2003 |
|
---|
2004 | /**
|
---|
2005 | * vprintf like function for writing to the default log.
|
---|
2006 | *
|
---|
2007 | * @param pszFormat Printf like format string.
|
---|
2008 | * @param args Optional arguments as specified in pszFormat.
|
---|
2009 | *
|
---|
2010 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
2011 | */
|
---|
2012 | RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list args);
|
---|
2013 |
|
---|
2014 | /**
|
---|
2015 | * Dumper vprintf-like function outputting to a logger.
|
---|
2016 | *
|
---|
2017 | * @param pvUser Pointer to the logger instance to use, NULL for
|
---|
2018 | * default instance.
|
---|
2019 | * @param pszFormat Format string.
|
---|
2020 | * @param va Format arguments.
|
---|
2021 | */
|
---|
2022 | RTDECL(void) RTLogDumpPrintfV(void *pvUser, const char *pszFormat, va_list va);
|
---|
2023 |
|
---|
2024 |
|
---|
2025 | #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
|
---|
2026 | #define DECLARED_FNRTSTROUTPUT
|
---|
2027 | /**
|
---|
2028 | * Output callback.
|
---|
2029 | *
|
---|
2030 | * @returns number of bytes written.
|
---|
2031 | * @param pvArg User argument.
|
---|
2032 | * @param pachChars Pointer to an array of utf-8 characters.
|
---|
2033 | * @param cbChars Number of bytes in the character array pointed to by pachChars.
|
---|
2034 | */
|
---|
2035 | typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg, const char *pachChars, size_t cbChars);
|
---|
2036 | /** Pointer to callback function. */
|
---|
2037 | typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
|
---|
2038 | #endif
|
---|
2039 |
|
---|
2040 | /**
|
---|
2041 | * Partial vsprintf worker implementation.
|
---|
2042 | *
|
---|
2043 | * @returns number of bytes formatted.
|
---|
2044 | * @param pfnOutput Output worker.
|
---|
2045 | * Called in two ways. Normally with a string an it's length.
|
---|
2046 | * For termination, it's called with NULL for string, 0 for length.
|
---|
2047 | * @param pvArg Argument to output worker.
|
---|
2048 | * @param pszFormat Format string.
|
---|
2049 | * @param args Argument list.
|
---|
2050 | */
|
---|
2051 | RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args);
|
---|
2052 |
|
---|
2053 | /**
|
---|
2054 | * Write log buffer to COM port.
|
---|
2055 | *
|
---|
2056 | * @param pach Pointer to the buffer to write.
|
---|
2057 | * @param cb Number of bytes to write.
|
---|
2058 | */
|
---|
2059 | RTDECL(void) RTLogWriteCom(const char *pach, size_t cb);
|
---|
2060 |
|
---|
2061 | /**
|
---|
2062 | * Prints a formatted string to the serial port used for logging.
|
---|
2063 | *
|
---|
2064 | * @returns Number of bytes written.
|
---|
2065 | * @param pszFormat Format string.
|
---|
2066 | * @param ... Optional arguments specified in the format string.
|
---|
2067 | */
|
---|
2068 | RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...);
|
---|
2069 |
|
---|
2070 | /**
|
---|
2071 | * Prints a formatted string to the serial port used for logging.
|
---|
2072 | *
|
---|
2073 | * @returns Number of bytes written.
|
---|
2074 | * @param pszFormat Format string.
|
---|
2075 | * @param args Optional arguments specified in the format string.
|
---|
2076 | */
|
---|
2077 | RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args);
|
---|
2078 |
|
---|
2079 |
|
---|
2080 | #if 0 /* not implemented yet */
|
---|
2081 |
|
---|
2082 | /** Indicates that the semaphores shall be used to notify the other
|
---|
2083 | * part about buffer changes. */
|
---|
2084 | #define LOGHOOKBUFFER_FLAGS_SEMAPHORED 1
|
---|
2085 |
|
---|
2086 | /**
|
---|
2087 | * Log Hook Buffer.
|
---|
2088 | * Use to communicate between the logger and a log consumer.
|
---|
2089 | */
|
---|
2090 | typedef struct RTLOGHOOKBUFFER
|
---|
2091 | {
|
---|
2092 | /** Write pointer. */
|
---|
2093 | volatile void *pvWrite;
|
---|
2094 | /** Read pointer. */
|
---|
2095 | volatile void *pvRead;
|
---|
2096 | /** Buffer start. */
|
---|
2097 | void *pvStart;
|
---|
2098 | /** Buffer end (exclusive). */
|
---|
2099 | void *pvEnd;
|
---|
2100 | /** Signaling semaphore used by the writer to wait on a full buffer.
|
---|
2101 | * Only used when indicated in flags. */
|
---|
2102 | void *pvSemWriter;
|
---|
2103 | /** Signaling semaphore used by the read to wait on an empty buffer.
|
---|
2104 | * Only used when indicated in flags. */
|
---|
2105 | void *pvSemReader;
|
---|
2106 | /** Buffer flags. Current reserved and set to zero. */
|
---|
2107 | volatile unsigned fFlags;
|
---|
2108 | } RTLOGHOOKBUFFER;
|
---|
2109 | /** Pointer to a log hook buffer. */
|
---|
2110 | typedef RTLOGHOOKBUFFER *PRTLOGHOOKBUFFER;
|
---|
2111 |
|
---|
2112 |
|
---|
2113 | /**
|
---|
2114 | * Register a logging hook.
|
---|
2115 | *
|
---|
2116 | * This type of logging hooks are expecting different threads acting
|
---|
2117 | * producer and consumer. They share a circular buffer which have two
|
---|
2118 | * pointers one for each end. When the buffer is full there are two
|
---|
2119 | * alternatives (indicated by a buffer flag), either wait for the
|
---|
2120 | * consumer to get it's job done, or to write a generic message saying
|
---|
2121 | * buffer overflow.
|
---|
2122 | *
|
---|
2123 | * Since the waiting would need a signal semaphore, we'll skip that for now.
|
---|
2124 | *
|
---|
2125 | * @returns iprt status code.
|
---|
2126 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
2127 | */
|
---|
2128 | RTDECL(int) RTLogRegisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
2129 |
|
---|
2130 | /**
|
---|
2131 | * Deregister a logging hook registered with RTLogRegisterHook().
|
---|
2132 | *
|
---|
2133 | * @returns iprt status code.
|
---|
2134 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
2135 | */
|
---|
2136 | RTDECL(int) RTLogDeregisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
2137 |
|
---|
2138 | #endif /* not implemented yet */
|
---|
2139 |
|
---|
2140 |
|
---|
2141 |
|
---|
2142 | /**
|
---|
2143 | * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
|
---|
2144 | *
|
---|
2145 | * @param pach What to write.
|
---|
2146 | * @param cb How much to write.
|
---|
2147 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2148 | */
|
---|
2149 | RTDECL(void) RTLogWriteDebugger(const char *pach, size_t cb);
|
---|
2150 |
|
---|
2151 | /**
|
---|
2152 | * Write log buffer to a user defined output stream (RTLOGDEST_USER).
|
---|
2153 | *
|
---|
2154 | * @param pach What to write.
|
---|
2155 | * @param cb How much to write.
|
---|
2156 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2157 | */
|
---|
2158 | RTDECL(void) RTLogWriteUser(const char *pach, size_t cb);
|
---|
2159 |
|
---|
2160 | /**
|
---|
2161 | * Write log buffer to stdout (RTLOGDEST_STDOUT).
|
---|
2162 | *
|
---|
2163 | * @param pach What to write.
|
---|
2164 | * @param cb How much to write.
|
---|
2165 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2166 | */
|
---|
2167 | RTDECL(void) RTLogWriteStdOut(const char *pach, size_t cb);
|
---|
2168 |
|
---|
2169 | /**
|
---|
2170 | * Write log buffer to stdout (RTLOGDEST_STDERR).
|
---|
2171 | *
|
---|
2172 | * @param pach What to write.
|
---|
2173 | * @param cb How much to write.
|
---|
2174 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
2175 | */
|
---|
2176 | RTDECL(void) RTLogWriteStdErr(const char *pach, size_t cb);
|
---|
2177 |
|
---|
2178 | #ifdef VBOX
|
---|
2179 |
|
---|
2180 | /**
|
---|
2181 | * Prints a formatted string to the backdoor port.
|
---|
2182 | *
|
---|
2183 | * @returns Number of bytes written.
|
---|
2184 | * @param pszFormat Format string.
|
---|
2185 | * @param ... Optional arguments specified in the format string.
|
---|
2186 | */
|
---|
2187 | RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...);
|
---|
2188 |
|
---|
2189 | /**
|
---|
2190 | * Prints a formatted string to the backdoor port.
|
---|
2191 | *
|
---|
2192 | * @returns Number of bytes written.
|
---|
2193 | * @param pszFormat Format string.
|
---|
2194 | * @param args Optional arguments specified in the format string.
|
---|
2195 | */
|
---|
2196 | RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args);
|
---|
2197 |
|
---|
2198 | #endif /* VBOX */
|
---|
2199 |
|
---|
2200 | RT_C_DECLS_END
|
---|
2201 |
|
---|
2202 | /** @} */
|
---|
2203 |
|
---|
2204 | #endif
|
---|
2205 |
|
---|