1 | /** @file
|
---|
2 | * innotek Portable Runtime - Logging.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 | __BEGIN_DECLS
|
---|
34 |
|
---|
35 | /** @defgroup grp_rt_log RTLog - Logging
|
---|
36 | * @ingroup grp_rt
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * innotek Portable Runtime 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_DIR,
|
---|
56 | RTLOGGROUP_FILE,
|
---|
57 | RTLOGGROUP_FS,
|
---|
58 | RTLOGGROUP_LDR,
|
---|
59 | RTLOGGROUP_PATH,
|
---|
60 | RTLOGGROUP_PROCESS,
|
---|
61 | RTLOGGROUP_THREAD,
|
---|
62 | RTLOGGROUP_TIME,
|
---|
63 | RTLOGGROUP_TIMER,
|
---|
64 | RTLOGGROUP_ZIP = 31,
|
---|
65 | RTLOGGROUP_FIRST_USER = 32
|
---|
66 | } RTLOGGROUP;
|
---|
67 |
|
---|
68 | /** @def RT_LOGGROUP_NAMES
|
---|
69 | * innotek Portable Runtime Logging group names.
|
---|
70 | *
|
---|
71 | * Must correspond 100% to RTLOGGROUP!
|
---|
72 | * Don't forget commas!
|
---|
73 | *
|
---|
74 | * @remark It should be pretty obvious, but just to have
|
---|
75 | * mentioned it, the values are sorted alphabetically (using the
|
---|
76 | * english alphabet) except for _DEFAULT which is always first.
|
---|
77 | *
|
---|
78 | * If anyone might be wondering what the alphabet looks like:
|
---|
79 | * 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
|
---|
80 | */
|
---|
81 | #define RT_LOGGROUP_NAMES \
|
---|
82 | "DEFAULT", \
|
---|
83 | "RT_DIR", \
|
---|
84 | "RT_FILE", \
|
---|
85 | "RT_FS", \
|
---|
86 | "RT_LDR", \
|
---|
87 | "RT_PATH", \
|
---|
88 | "RT_PROCESS", \
|
---|
89 | "RT_THREAD", \
|
---|
90 | "RT_TIME", \
|
---|
91 | "RT_TIMER", \
|
---|
92 | "RT_10", \
|
---|
93 | "RT_11", \
|
---|
94 | "RT_12", \
|
---|
95 | "RT_13", \
|
---|
96 | "RT_14", \
|
---|
97 | "RT_15", \
|
---|
98 | "RT_16", \
|
---|
99 | "RT_17", \
|
---|
100 | "RT_18", \
|
---|
101 | "RT_19", \
|
---|
102 | "RT_20", \
|
---|
103 | "RT_21", \
|
---|
104 | "RT_22", \
|
---|
105 | "RT_23", \
|
---|
106 | "RT_24", \
|
---|
107 | "RT_25", \
|
---|
108 | "RT_26", \
|
---|
109 | "RT_27", \
|
---|
110 | "RT_28", \
|
---|
111 | "RT_29", \
|
---|
112 | "RT_30", \
|
---|
113 | "RT_ZIP" \
|
---|
114 |
|
---|
115 |
|
---|
116 | /** @def LOG_GROUP
|
---|
117 | * Active logging group.
|
---|
118 | */
|
---|
119 | #ifndef LOG_GROUP
|
---|
120 | # define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
121 | #endif
|
---|
122 |
|
---|
123 | /** @def LOG_INSTANCE
|
---|
124 | * Active logging instance.
|
---|
125 | */
|
---|
126 | #ifndef LOG_INSTANCE
|
---|
127 | # define LOG_INSTANCE NULL
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | /** @def LOG_REL_INSTANCE
|
---|
131 | * Active release logging instance.
|
---|
132 | */
|
---|
133 | #ifndef LOG_REL_INSTANCE
|
---|
134 | # define LOG_REL_INSTANCE NULL
|
---|
135 | #endif
|
---|
136 |
|
---|
137 |
|
---|
138 | /** Logger structure. */
|
---|
139 | #ifdef IN_GC
|
---|
140 | typedef struct RTLOGGERGC RTLOGGER;
|
---|
141 | #else
|
---|
142 | typedef struct RTLOGGER RTLOGGER;
|
---|
143 | #endif
|
---|
144 | /** Pointer to logger structure. */
|
---|
145 | typedef RTLOGGER *PRTLOGGER;
|
---|
146 | /** Pointer to const logger structure. */
|
---|
147 | typedef const RTLOGGER *PCRTLOGGER;
|
---|
148 |
|
---|
149 |
|
---|
150 | /** Guest context logger structure. */
|
---|
151 | typedef struct RTLOGGERGC RTLOGGERGC;
|
---|
152 | /** Pointer to guest context logger structure. */
|
---|
153 | typedef RTLOGGERGC *PRTLOGGERGC;
|
---|
154 | /** Pointer to const guest context logger structure. */
|
---|
155 | typedef const RTLOGGERGC *PCRTLOGGERGC;
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Logger function.
|
---|
160 | *
|
---|
161 | * @param pszFormat Format string.
|
---|
162 | * @param ... Optional arguments as specified in the format string.
|
---|
163 | */
|
---|
164 | typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...);
|
---|
165 | /** Pointer to logger function. */
|
---|
166 | typedef FNRTLOGGER *PFNRTLOGGER;
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * Flush function.
|
---|
170 | *
|
---|
171 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
172 | */
|
---|
173 | typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger);
|
---|
174 | /** Pointer to logger function. */
|
---|
175 | typedef FNRTLOGFLUSH *PFNRTLOGFLUSH;
|
---|
176 |
|
---|
177 | /**
|
---|
178 | * Flush function.
|
---|
179 | *
|
---|
180 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
181 | */
|
---|
182 | typedef DECLCALLBACK(void) FNRTLOGFLUSHGC(PRTLOGGERGC pLogger);
|
---|
183 | /** Pointer to logger function. */
|
---|
184 | typedef GCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC;
|
---|
185 |
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * Logger instance structure for GC.
|
---|
189 | */
|
---|
190 | struct RTLOGGERGC
|
---|
191 | {
|
---|
192 | /** Pointer to temporary scratch buffer.
|
---|
193 | * This is used to format the log messages. */
|
---|
194 | char achScratch[16384];
|
---|
195 | /** Current scratch buffer position. */
|
---|
196 | RTUINT offScratch;
|
---|
197 | /** This is set if a prefix is pending. */
|
---|
198 | RTUINT fPendingPrefix;
|
---|
199 | /** Pointer to the logger function.
|
---|
200 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
201 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
202 | * A very unfortunate hack to work around the missing variadic macro support in C++. */
|
---|
203 | GCPTRTYPE(PFNRTLOGGER) pfnLogger;
|
---|
204 | /** Pointer to the flush function. */
|
---|
205 | PFNRTLOGFLUSHGC pfnFlush;
|
---|
206 | /** Magic number (RTLOGGERGC_MAGIC). */
|
---|
207 | uint32_t u32Magic;
|
---|
208 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
209 | RTUINT fFlags;
|
---|
210 | /** Number of groups in the afGroups member. */
|
---|
211 | RTUINT cGroups;
|
---|
212 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
213 | * This member have variable length and may extend way beyond
|
---|
214 | * the declared size of 1 entry. */
|
---|
215 | RTUINT afGroups[1];
|
---|
216 | };
|
---|
217 |
|
---|
218 | /** RTLOGGERGC::u32Magic value. (John Rogers Searle) */
|
---|
219 | #define RTLOGGERGC_MAGIC 0x19320731
|
---|
220 |
|
---|
221 |
|
---|
222 |
|
---|
223 | #ifndef IN_GC
|
---|
224 | /**
|
---|
225 | * Logger instance structure.
|
---|
226 | */
|
---|
227 | struct RTLOGGER
|
---|
228 | {
|
---|
229 | /** Pointer to temporary scratch buffer.
|
---|
230 | * This is used to format the log messages. */
|
---|
231 | char achScratch[16384];
|
---|
232 | /** Current scratch buffer position. */
|
---|
233 | RTUINT offScratch;
|
---|
234 | /** This is set if a prefix is pending. */
|
---|
235 | RTUINT fPendingPrefix;
|
---|
236 | /** Pointer to the logger function.
|
---|
237 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
238 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
239 | * A very unfortunate hack to work around the missing variadic macro support in C++.
|
---|
240 | * (The memory is (not R0) allocated using RTMemExecAlloc().) */
|
---|
241 | PFNRTLOGGER pfnLogger;
|
---|
242 | /** Pointer to the flush function. */
|
---|
243 | PFNRTLOGFLUSH pfnFlush;
|
---|
244 | /** Mutex. */
|
---|
245 | RTSEMFASTMUTEX MutexSem;
|
---|
246 | /** Magic number. */
|
---|
247 | uint32_t u32Magic;
|
---|
248 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
249 | RTUINT fFlags;
|
---|
250 | /** Destination flags - RTLOGDEST. */
|
---|
251 | RTUINT fDestFlags;
|
---|
252 | /** Handle to log file (if open). */
|
---|
253 | RTFILE File;
|
---|
254 | /** Pointer to filename.
|
---|
255 | * (The memory is allocated in the smae block as RTLOGGER.) */
|
---|
256 | char *pszFilename;
|
---|
257 | /** Pointer to the group name array.
|
---|
258 | * (The data is readonly and provided by the user.) */
|
---|
259 | const char * const *papszGroups;
|
---|
260 | /** The max number of groups that there is room for in afGroups and papszGroups.
|
---|
261 | * Used by RTLogCopyGroupAndFlags(). */
|
---|
262 | RTUINT cMaxGroups;
|
---|
263 | /** Number of groups in the afGroups and papszGroups members. */
|
---|
264 | RTUINT cGroups;
|
---|
265 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
266 | * This member have variable length and may extend way beyond
|
---|
267 | * the declared size of 1 entry. */
|
---|
268 | RTUINT afGroups[1];
|
---|
269 | };
|
---|
270 |
|
---|
271 | /** RTLOGGER::u32Magic value. (Avram Noam Chomsky) */
|
---|
272 | #define RTLOGGER_MAGIC 0x19281207
|
---|
273 |
|
---|
274 | #endif
|
---|
275 |
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * Logger flags.
|
---|
279 | */
|
---|
280 | typedef enum RTLOGFLAGS
|
---|
281 | {
|
---|
282 | /** The logger instance is disabled for normal output. */
|
---|
283 | RTLOGFLAGS_DISABLED = 0x00000001,
|
---|
284 | /** The logger instance is using buffered output. */
|
---|
285 | RTLOGFLAGS_BUFFERED = 0x00000002,
|
---|
286 | /** The logger instance expands LF to CR/LF. */
|
---|
287 | RTLOGFLAGS_USECRLF = 0x00000010,
|
---|
288 | /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
289 | RTLOGFLAGS_REL_TS = 0x00010000,
|
---|
290 | /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
291 | RTLOGFLAGS_DECIMAL_TS = 0x00020000,
|
---|
292 | /** New lines should be prefixed with group flag number causing the output. */
|
---|
293 | RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,
|
---|
294 | /** New lines should be prefixed with group flag name causing the output. */
|
---|
295 | RTLOGFLAGS_PREFIX_FLAG = 0x00080000,
|
---|
296 | /** New lines should be prefixed with group number. */
|
---|
297 | RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,
|
---|
298 | /** New lines should be prefixed with group name. */
|
---|
299 | RTLOGFLAGS_PREFIX_GROUP = 0x00200000,
|
---|
300 | /** New lines should be prefixed with the native thread id. */
|
---|
301 | RTLOGFLAGS_PREFIX_TID = 0x00400000,
|
---|
302 | /** New lines should be prefixed with thread name. */
|
---|
303 | RTLOGFLAGS_PREFIX_THREAD = 0x00800000,
|
---|
304 | /** New lines should be prefixed with formatted timestamp since program start. */
|
---|
305 | RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
|
---|
306 | /** New lines should be prefixed with formatted timestamp (UCT). */
|
---|
307 | RTLOGFLAGS_PREFIX_TIME = 0x08000000,
|
---|
308 | /** New lines should be prefixed with milliseconds since program start. */
|
---|
309 | RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,
|
---|
310 | /** New lines should be prefixed with timestamp. */
|
---|
311 | RTLOGFLAGS_PREFIX_TSC = 0x20000000,
|
---|
312 | /** New lines should be prefixed with timestamp. */
|
---|
313 | RTLOGFLAGS_PREFIX_TS = 0x40000000,
|
---|
314 | /** The prefix mask. */
|
---|
315 | RTLOGFLAGS_PREFIX_MASK = 0x7cff0000
|
---|
316 | } RTLOGFLAGS;
|
---|
317 |
|
---|
318 | /**
|
---|
319 | * Logger per group flags.
|
---|
320 | */
|
---|
321 | typedef enum RTLOGGRPFLAGS
|
---|
322 | {
|
---|
323 | /** Enabled. */
|
---|
324 | RTLOGGRPFLAGS_ENABLED = 0x00000001,
|
---|
325 | /** Level 1 logging. */
|
---|
326 | RTLOGGRPFLAGS_LEVEL_1 = 0x00000002,
|
---|
327 | /** Level 2 logging. */
|
---|
328 | RTLOGGRPFLAGS_LEVEL_2 = 0x00000004,
|
---|
329 | /** Level 3 logging. */
|
---|
330 | RTLOGGRPFLAGS_LEVEL_3 = 0x00000008,
|
---|
331 | /** Level 4 logging. */
|
---|
332 | RTLOGGRPFLAGS_LEVEL_4 = 0x00000010,
|
---|
333 | /** Level 5 logging. */
|
---|
334 | RTLOGGRPFLAGS_LEVEL_5 = 0x00000020,
|
---|
335 | /** Level 6 logging. */
|
---|
336 | RTLOGGRPFLAGS_LEVEL_6 = 0x00000040,
|
---|
337 | /** Flow logging. */
|
---|
338 | RTLOGGRPFLAGS_FLOW = 0x00000080,
|
---|
339 |
|
---|
340 | /** Lelik logging. */
|
---|
341 | RTLOGGRPFLAGS_LELIK = 0x00000100,
|
---|
342 | /** Michael logging. */
|
---|
343 | RTLOGGRPFLAGS_MICHAEL = 0x00000200,
|
---|
344 | /** dmik logging. */
|
---|
345 | RTLOGGRPFLAGS_DMIK = 0x00000400,
|
---|
346 | /** sunlover logging. */
|
---|
347 | RTLOGGRPFLAGS_SUNLOVER = 0x00000800,
|
---|
348 | /** Achim logging. */
|
---|
349 | RTLOGGRPFLAGS_ACHIM = 0x00001000,
|
---|
350 | /** Sander logging. */
|
---|
351 | RTLOGGRPFLAGS_SANDER = 0x00002000,
|
---|
352 | /** Klaus logging. */
|
---|
353 | RTLOGGRPFLAGS_KLAUS = 0x00004000,
|
---|
354 | /** Frank logging. */
|
---|
355 | RTLOGGRPFLAGS_FRANK = 0x00008000,
|
---|
356 | /** bird logging. */
|
---|
357 | RTLOGGRPFLAGS_BIRD = 0x00010000,
|
---|
358 | /** NoName logging. */
|
---|
359 | RTLOGGRPFLAGS_NONAME = 0x00020000
|
---|
360 | } RTLOGGRPFLAGS;
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Logger destination type.
|
---|
364 | */
|
---|
365 | typedef enum RTLOGDEST
|
---|
366 | {
|
---|
367 | /** Log to file. */
|
---|
368 | RTLOGDEST_FILE = 0x00000001,
|
---|
369 | /** Log to stdout. */
|
---|
370 | RTLOGDEST_STDOUT = 0x00000002,
|
---|
371 | /** Log to stderr. */
|
---|
372 | RTLOGDEST_STDERR = 0x00000004,
|
---|
373 | /** Log to debugger (win32 only). */
|
---|
374 | RTLOGDEST_DEBUGGER = 0x00000008,
|
---|
375 | /** Log to com port. */
|
---|
376 | RTLOGDEST_COM = 0x00000010,
|
---|
377 | /** Just a dummy flag to be used when no other flag applies. */
|
---|
378 | RTLOGDEST_DUMMY = 0x20000000,
|
---|
379 | /** Log to a user defined output stream. */
|
---|
380 | RTLOGDEST_USER = 0x40000000
|
---|
381 | } RTLOGDEST;
|
---|
382 |
|
---|
383 |
|
---|
384 | RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
385 |
|
---|
386 |
|
---|
387 | /*
|
---|
388 | * Determin whether logging is enabled and forcefully normalize the indicators.
|
---|
389 | */
|
---|
390 | #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
|
---|
391 | # undef LOG_DISABLED
|
---|
392 | # undef LOG_ENABLED
|
---|
393 | # define LOG_ENABLED
|
---|
394 | #else
|
---|
395 | # undef LOG_ENABLED
|
---|
396 | # undef LOG_DISABLED
|
---|
397 | # define LOG_DISABLED
|
---|
398 | #endif
|
---|
399 |
|
---|
400 |
|
---|
401 | /** @def LogIt
|
---|
402 | * Write to specific logger if group enabled.
|
---|
403 | */
|
---|
404 | #ifdef LOG_ENABLED
|
---|
405 | # if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
|
---|
406 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
407 | # define _LogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
|
---|
408 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) _LogIt(pvInst, fFlags, iGroup, _LogRemoveParentheseis fmtargs)
|
---|
409 | # else
|
---|
410 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
411 | do \
|
---|
412 | { \
|
---|
413 | register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \
|
---|
414 | if (LogIt_pLogger) \
|
---|
415 | { \
|
---|
416 | register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
|
---|
417 | if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
418 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
419 | } \
|
---|
420 | } while (0)
|
---|
421 | # endif
|
---|
422 | #else
|
---|
423 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) do { } while (0)
|
---|
424 | #endif
|
---|
425 |
|
---|
426 |
|
---|
427 | /** @def Log
|
---|
428 | * Level 1 logging.
|
---|
429 | */
|
---|
430 | #define Log(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
431 |
|
---|
432 | /** @def Log2
|
---|
433 | * Level 2 logging.
|
---|
434 | */
|
---|
435 | #define Log2(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
436 |
|
---|
437 | /** @def Log3
|
---|
438 | * Level 3 logging.
|
---|
439 | */
|
---|
440 | #define Log3(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
441 |
|
---|
442 | /** @def Log4
|
---|
443 | * Level 4 logging.
|
---|
444 | */
|
---|
445 | #define Log4(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
446 |
|
---|
447 | /** @def Log5
|
---|
448 | * Level 5 logging.
|
---|
449 | */
|
---|
450 | #define Log5(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
451 |
|
---|
452 | /** @def Log6
|
---|
453 | * Level 6 logging.
|
---|
454 | */
|
---|
455 | #define Log6(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
456 |
|
---|
457 | /** @def LogFlow
|
---|
458 | * Logging of execution flow.
|
---|
459 | */
|
---|
460 | #define LogFlow(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
461 |
|
---|
462 | /** @def LogLelik
|
---|
463 | * lelik logging.
|
---|
464 | */
|
---|
465 | #define LogLelik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
466 |
|
---|
467 |
|
---|
468 | /** @def LogMichael
|
---|
469 | * michael logging.
|
---|
470 | */
|
---|
471 | #define LogMichael(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
472 |
|
---|
473 | /** @def LogDmik
|
---|
474 | * dmik logging.
|
---|
475 | */
|
---|
476 | #define LogDmik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_DMIK, LOG_GROUP, a)
|
---|
477 |
|
---|
478 | /** @def LogSunlover
|
---|
479 | * sunlover logging.
|
---|
480 | */
|
---|
481 | #define LogSunlover(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
482 |
|
---|
483 | /** @def LogAchim
|
---|
484 | * Achim logging.
|
---|
485 | */
|
---|
486 | #define LogAchim(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
487 |
|
---|
488 | /** @def LogSander
|
---|
489 | * Sander logging.
|
---|
490 | */
|
---|
491 | #define LogSander(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
492 |
|
---|
493 | /** @def LogKlaus
|
---|
494 | * klaus logging.
|
---|
495 | */
|
---|
496 | #define LogKlaus(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
497 |
|
---|
498 | /** @def LogFrank
|
---|
499 | * frank logging.
|
---|
500 | */
|
---|
501 | #define LogFrank(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
502 |
|
---|
503 | /** @def LogBird
|
---|
504 | * bird logging.
|
---|
505 | */
|
---|
506 | #define LogBird(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
507 |
|
---|
508 | /** @def LogNoName
|
---|
509 | * NoName logging.
|
---|
510 | */
|
---|
511 | #define LogNoName(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
512 |
|
---|
513 |
|
---|
514 | /** @def LogWarning
|
---|
515 | * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
|
---|
516 | * @param m custom log message in format <tt>("string\n" [, args])</tt>
|
---|
517 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
518 | * join two separate Log* calls and make this op atomic
|
---|
519 | */
|
---|
520 | #define LogWarning(m) \
|
---|
521 | do { Log(("WARNING! ")); Log(m); } while (0)
|
---|
522 |
|
---|
523 | /** @def LogTrace
|
---|
524 | * Macro to trace the execution flow: logs the file name, line number and
|
---|
525 | * function name. Can be easily searched for in log files using the
|
---|
526 | * ">>>>>" pattern (prepended to the beginning of each line).
|
---|
527 | */
|
---|
528 | #define LogTrace() \
|
---|
529 | LogFlow((">>>>> %s (%d): %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__))
|
---|
530 |
|
---|
531 | /** @def LogTraceMsg
|
---|
532 | * The same as LogTrace but logs a custom log message right after the trace line.
|
---|
533 | * @param m custom log message in format <tt>("string\n" [, args])</tt>
|
---|
534 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
535 | * join two separate Log* calls and make this op atomic
|
---|
536 | */
|
---|
537 | #define LogTraceMsg(m) \
|
---|
538 | do { LogTrace(); LogFlow(m); } while (0)
|
---|
539 |
|
---|
540 | /** @def LogFunc
|
---|
541 | * Level 1 logging inside C/C++ functions.
|
---|
542 | * Prepends the given log message with the function name followed by a semicolon
|
---|
543 | * and space.
|
---|
544 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
545 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
546 | * join two separate Log* calls and make this op atomic
|
---|
547 | */
|
---|
548 | #define LogFunc(m) \
|
---|
549 | do { Log(("%s: ", __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
550 |
|
---|
551 | /** @def LogThisFunc
|
---|
552 | * The same as LogFunc but for class functions (methods): the resulting log
|
---|
553 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
554 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
555 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
556 | * join two separate Log* calls and make this op atomic
|
---|
557 | */
|
---|
558 | #define LogThisFunc(m) \
|
---|
559 | do { Log(("{%p} %s: ", this, __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
560 |
|
---|
561 | /** @def LogFlowFunc
|
---|
562 | * Macro to log the execution flow inside C/C++ functions.
|
---|
563 | * Prepends the given log message with the function name followed by a semicolon
|
---|
564 | * and space.
|
---|
565 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
566 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
567 | * join two separate Log* calls and make this op atomic
|
---|
568 | */
|
---|
569 | #define LogFlowFunc(m) \
|
---|
570 | do { LogFlow(("%s: ", __PRETTY_FUNCTION__)); LogFlow(m); } while (0)
|
---|
571 |
|
---|
572 | /** @def LogWarningFunc
|
---|
573 | * The same as LogWarning(), but prepents the log message with the function name.
|
---|
574 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
575 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
576 | * join two separate Log* calls and make this op atomic
|
---|
577 | */
|
---|
578 | #define LogWarningFunc(m) \
|
---|
579 | do { Log(("%s: WARNING! ", __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
580 |
|
---|
581 | /** @def LogFlowThisFunc
|
---|
582 | * The same as LogFlowFunc but for class functions (methods): the resulting log
|
---|
583 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
584 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
585 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
586 | * join two separate Log* calls and make this op atomic
|
---|
587 | */
|
---|
588 | #define LogFlowThisFunc(m) \
|
---|
589 | do { LogFlow(("{%p} %s: ", this, __PRETTY_FUNCTION__)); LogFlow(m); } while (0)
|
---|
590 |
|
---|
591 | /** @def LogWarningThisFunc
|
---|
592 | * The same as LogWarningFunc() but for class functions (methods): the resulting
|
---|
593 | * log line is additionally perpended with a hex value of |this| pointer.
|
---|
594 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
595 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
596 | * join two separate Log* calls and make this op atomic
|
---|
597 | */
|
---|
598 | #define LogWarningThisFunc(m) \
|
---|
599 | do { Log(("{%p} %s: WARNING! ", this, __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
600 |
|
---|
601 | /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function */
|
---|
602 | #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
|
---|
603 |
|
---|
604 | /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function */
|
---|
605 | #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
|
---|
606 |
|
---|
607 | /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function */
|
---|
608 | #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
|
---|
609 |
|
---|
610 | /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function */
|
---|
611 | #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
|
---|
612 |
|
---|
613 | /** @def LogObjRefCnt
|
---|
614 | * Helper macro to print the current reference count of the given COM object
|
---|
615 | * to the log file.
|
---|
616 | * @param obj object in question (must be a pointer to an IUnknown subclass
|
---|
617 | * or simply define COM-style AddRef() and Release() methods)
|
---|
618 | * @note Use it only for temporary debugging. It leaves dummy code even if
|
---|
619 | * logging is disabled.
|
---|
620 | */
|
---|
621 | #define LogObjRefCnt(obj) \
|
---|
622 | do { \
|
---|
623 | int refc = (obj)->AddRef(); -- refc; \
|
---|
624 | LogFlow((#obj "{%p}.refCnt=%d\n", (obj), refc)); \
|
---|
625 | (obj)->Release(); \
|
---|
626 | } while (0)
|
---|
627 |
|
---|
628 |
|
---|
629 | /** @def LogIsItEnabled
|
---|
630 | * Checks whether the specified logging group is enabled or not.
|
---|
631 | */
|
---|
632 | #ifdef LOG_ENABLED
|
---|
633 | # define LogIsItEnabled(pvInst, fFlags, iGroup) \
|
---|
634 | LogIsItEnabledInternal((pvInst), (unsigned)(iGroup), (unsigned)(fFlags))
|
---|
635 | #else
|
---|
636 | # define LogIsItEnabled(pvInst, fFlags, iGroup) (false)
|
---|
637 | #endif
|
---|
638 |
|
---|
639 | /** @def LogIsEnabled
|
---|
640 | * Checks whether level 1 logging is enabled.
|
---|
641 | */
|
---|
642 | #define LogIsEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
643 |
|
---|
644 | /** @def LogIs2Enabled
|
---|
645 | * Checks whether level 2 logging is enabled.
|
---|
646 | */
|
---|
647 | #define LogIs2Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
648 |
|
---|
649 | /** @def LogIs3Enabled
|
---|
650 | * Checks whether level 3 logging is enabled.
|
---|
651 | */
|
---|
652 | #define LogIs3Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
653 |
|
---|
654 | /** @def LogIs4Enabled
|
---|
655 | * Checks whether level 4 logging is enabled.
|
---|
656 | */
|
---|
657 | #define LogIs4Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
658 |
|
---|
659 | /** @def LogIs5Enabled
|
---|
660 | * Checks whether level 5 logging is enabled.
|
---|
661 | */
|
---|
662 | #define LogIs5Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
663 |
|
---|
664 | /** @def LogIs6Enabled
|
---|
665 | * Checks whether level 6 logging is enabled.
|
---|
666 | */
|
---|
667 | #define LogIs6Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
668 |
|
---|
669 | /** @def LogIsFlowEnabled
|
---|
670 | * Checks whether execution flow logging is enabled.
|
---|
671 | */
|
---|
672 | #define LogIsFlowEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
673 |
|
---|
674 |
|
---|
675 | #ifdef __DOXYGEN__
|
---|
676 | # define LOG_DISABLED
|
---|
677 | # define LOG_ENABLED
|
---|
678 | # define LOG_ENABLE_FLOW
|
---|
679 | #endif
|
---|
680 |
|
---|
681 | /** @def LOG_DISABLED
|
---|
682 | * Use this compile time define to disable all logging macros. It can
|
---|
683 | * be overriden for each of the logging macros by the LOG_ENABLE*
|
---|
684 | * compile time defines.
|
---|
685 | */
|
---|
686 |
|
---|
687 | /** @def LOG_ENABLED
|
---|
688 | * Use this compile time define to enable logging when not in debug mode
|
---|
689 | * or LOG_DISABLED is set.
|
---|
690 | * This will enabled Log() only.
|
---|
691 | */
|
---|
692 |
|
---|
693 | /** @def LOG_ENABLE_FLOW
|
---|
694 | * Use this compile time define to enable flow logging when not in
|
---|
695 | * debug mode or LOG_DISABLED is defined.
|
---|
696 | * This will enable LogFlow() only.
|
---|
697 | */
|
---|
698 |
|
---|
699 |
|
---|
700 |
|
---|
701 | /** @name Release Logging
|
---|
702 | * @{
|
---|
703 | */
|
---|
704 |
|
---|
705 | /** @def LogIt
|
---|
706 | * Write to specific logger if group enabled.
|
---|
707 | */
|
---|
708 | #if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
|
---|
709 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
710 | # define _LogRelIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
|
---|
711 | # define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
712 | do \
|
---|
713 | { \
|
---|
714 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \
|
---|
715 | if (LogRelIt_pLogger) \
|
---|
716 | _LogRelIt(LogRelIt_pLogger, fFlags, iGroup, _LogRelRemoveParentheseis fmtargs); \
|
---|
717 | LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \
|
---|
718 | } while (0)
|
---|
719 | #else
|
---|
720 | # define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
721 | do \
|
---|
722 | { \
|
---|
723 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \
|
---|
724 | if (LogRelIt_pLogger) \
|
---|
725 | { \
|
---|
726 | unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
|
---|
727 | if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
728 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
729 | } \
|
---|
730 | LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \
|
---|
731 | } while (0)
|
---|
732 | #endif
|
---|
733 |
|
---|
734 |
|
---|
735 | /** @def LogRel
|
---|
736 | * Level 1 logging.
|
---|
737 | */
|
---|
738 | #define LogRel(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
739 |
|
---|
740 | /** @def LogRel2
|
---|
741 | * Level 2 logging.
|
---|
742 | */
|
---|
743 | #define LogRel2(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
744 |
|
---|
745 | /** @def LogRel3
|
---|
746 | * Level 3 logging.
|
---|
747 | */
|
---|
748 | #define LogRel3(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
749 |
|
---|
750 | /** @def LogRel4
|
---|
751 | * Level 4 logging.
|
---|
752 | */
|
---|
753 | #define LogRel4(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
754 |
|
---|
755 | /** @def LogRel5
|
---|
756 | * Level 5 logging.
|
---|
757 | */
|
---|
758 | #define LogRel5(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
759 |
|
---|
760 | /** @def LogRel6
|
---|
761 | * Level 6 logging.
|
---|
762 | */
|
---|
763 | #define LogRel6(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
764 |
|
---|
765 | /** @def LogRelFlow
|
---|
766 | * Logging of execution flow.
|
---|
767 | */
|
---|
768 | #define LogRelFlow(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
769 |
|
---|
770 | /** @def LogRelFunc
|
---|
771 | * Release logging. Prepends the given log message with the function name
|
---|
772 | * followed by a semicolon and space.
|
---|
773 | */
|
---|
774 | #define LogRelFunc(a) \
|
---|
775 | do { LogRel(("%s: ", __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
776 |
|
---|
777 | /** @def LogRelThisFunc
|
---|
778 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
779 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
780 | */
|
---|
781 | #define LogRelThisFunc(a) \
|
---|
782 | do { LogRel(("{%p} %s: ", this, __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
783 |
|
---|
784 | /** @def LogRelLelik
|
---|
785 | * lelik logging.
|
---|
786 | */
|
---|
787 | #define LogRelLelik(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
788 |
|
---|
789 | /** @def LogRelMichael
|
---|
790 | * michael logging.
|
---|
791 | */
|
---|
792 | #define LogRelMichael(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
793 |
|
---|
794 | /** @def LogRelDmik
|
---|
795 | * dmik logging.
|
---|
796 | */
|
---|
797 | #define LogRelDmik(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_DMIK, LOG_GROUP, a)
|
---|
798 |
|
---|
799 | /** @def LogRelSunlover
|
---|
800 | * sunlover logging.
|
---|
801 | */
|
---|
802 | #define LogRelSunlover(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
803 |
|
---|
804 | /** @def LogRelAchim
|
---|
805 | * Achim logging.
|
---|
806 | */
|
---|
807 | #define LogRelAchim(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
808 |
|
---|
809 | /** @def LogRelSander
|
---|
810 | * Sander logging.
|
---|
811 | */
|
---|
812 | #define LogRelSander(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
813 |
|
---|
814 | /** @def LogRelKlaus
|
---|
815 | * klaus logging.
|
---|
816 | */
|
---|
817 | #define LogRelKlaus(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
818 |
|
---|
819 | /** @def LogRelFrank
|
---|
820 | * frank logging.
|
---|
821 | */
|
---|
822 | #define LogRelFrank(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
823 |
|
---|
824 | /** @def LogRelBird
|
---|
825 | * bird logging.
|
---|
826 | */
|
---|
827 | #define LogRelBird(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
828 |
|
---|
829 | /** @def LogRelNoName
|
---|
830 | * NoName logging.
|
---|
831 | */
|
---|
832 | #define LogRelNoName(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
833 |
|
---|
834 |
|
---|
835 | /** @def LogRelIsItEnabled
|
---|
836 | * Checks whether the specified logging group is enabled or not.
|
---|
837 | */
|
---|
838 | #define LogRelIsItEnabled(pvInst, fFlags, iGroup) \
|
---|
839 | LogRelIsItEnabledInternal((pvInst), (unsigned)(iGroup), (unsigned)(fFlags))
|
---|
840 |
|
---|
841 | /** @def LogRelIsEnabled
|
---|
842 | * Checks whether level 1 logging is enabled.
|
---|
843 | */
|
---|
844 | #define LogRelIsEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
845 |
|
---|
846 | /** @def LogRelIs2Enabled
|
---|
847 | * Checks whether level 2 logging is enabled.
|
---|
848 | */
|
---|
849 | #define LogRelIs2Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
850 |
|
---|
851 | /** @def LogRelIs3Enabled
|
---|
852 | * Checks whether level 3 logging is enabled.
|
---|
853 | */
|
---|
854 | #define LogRelIs3Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
855 |
|
---|
856 | /** @def LogRelIs4Enabled
|
---|
857 | * Checks whether level 4 logging is enabled.
|
---|
858 | */
|
---|
859 | #define LogRelIs4Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
860 |
|
---|
861 | /** @def LogRelIs5Enabled
|
---|
862 | * Checks whether level 5 logging is enabled.
|
---|
863 | */
|
---|
864 | #define LogRelIs5Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
865 |
|
---|
866 | /** @def LogRelIs6Enabled
|
---|
867 | * Checks whether level 6 logging is enabled.
|
---|
868 | */
|
---|
869 | #define LogRelIs6Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
870 |
|
---|
871 | /** @def LogRelIsFlowEnabled
|
---|
872 | * Checks whether execution flow logging is enabled.
|
---|
873 | */
|
---|
874 | #define LogRelIsFlowEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
875 |
|
---|
876 |
|
---|
877 | #ifndef IN_GC
|
---|
878 | /**
|
---|
879 | * Sets the default release logger instance.
|
---|
880 | *
|
---|
881 | * @returns The old default instance.
|
---|
882 | * @param pLogger The new default release logger instance.
|
---|
883 | */
|
---|
884 | RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger);
|
---|
885 | #endif /* !IN_GC */
|
---|
886 |
|
---|
887 | /**
|
---|
888 | * Gets the default release logger instance.
|
---|
889 | *
|
---|
890 | * @returns Pointer to default release logger instance.
|
---|
891 | * @returns NULL if no default release logger instance available.
|
---|
892 | */
|
---|
893 | RTDECL(PRTLOGGER) RTLogRelDefaultInstance(void);
|
---|
894 |
|
---|
895 | /** Internal worker function.
|
---|
896 | * Don't call directly, use the LogRelIsItEnabled macro!
|
---|
897 | */
|
---|
898 | DECLINLINE(bool) LogRelIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
899 | {
|
---|
900 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogRelDefaultInstance();
|
---|
901 | if (pLogger)
|
---|
902 | {
|
---|
903 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
904 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
905 | return true;
|
---|
906 | }
|
---|
907 | return false;
|
---|
908 | }
|
---|
909 |
|
---|
910 | /**
|
---|
911 | * Write to a logger instance, defaulting to the release one.
|
---|
912 | *
|
---|
913 | * This function will check whether the instance, group and flags makes up a
|
---|
914 | * logging kind which is currently enabled before writing anything to the log.
|
---|
915 | *
|
---|
916 | * @param pLogger Pointer to logger instance.
|
---|
917 | * @param fFlags The logging flags.
|
---|
918 | * @param iGroup The group.
|
---|
919 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
920 | * only for internal usage!
|
---|
921 | * @param pszFormat Format string.
|
---|
922 | * @param ... Format arguments.
|
---|
923 | * @remark This is a worker function for LogRelIt.
|
---|
924 | */
|
---|
925 | RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
926 |
|
---|
927 | /**
|
---|
928 | * Write to a logger instance, defaulting to the release one.
|
---|
929 | *
|
---|
930 | * This function will check whether the instance, group and flags makes up a
|
---|
931 | * logging kind which is currently enabled before writing anything to the log.
|
---|
932 | *
|
---|
933 | * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
|
---|
934 | * @param fFlags The logging flags.
|
---|
935 | * @param iGroup The group.
|
---|
936 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
937 | * only for internal usage!
|
---|
938 | * @param pszFormat Format string.
|
---|
939 | * @param args Format arguments.
|
---|
940 | */
|
---|
941 | RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
942 |
|
---|
943 | /**
|
---|
944 | * printf like function for writing to the default release log.
|
---|
945 | *
|
---|
946 | * @param pszFormat Printf like format string.
|
---|
947 | * @param ... Optional arguments as specified in pszFormat.
|
---|
948 | *
|
---|
949 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
950 | */
|
---|
951 | RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...);
|
---|
952 |
|
---|
953 | /**
|
---|
954 | * vprintf like function for writing to the default release log.
|
---|
955 | *
|
---|
956 | * @param pszFormat Printf like format string.
|
---|
957 | * @param args Optional arguments as specified in pszFormat.
|
---|
958 | *
|
---|
959 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
960 | */
|
---|
961 | RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args);
|
---|
962 |
|
---|
963 |
|
---|
964 | /** @} */
|
---|
965 |
|
---|
966 |
|
---|
967 |
|
---|
968 | /** @name COM port logging
|
---|
969 | * {
|
---|
970 | */
|
---|
971 |
|
---|
972 | #ifdef __DOXYGEN__
|
---|
973 | # define LOG_TO_COM
|
---|
974 | # define LOG_NO_COM
|
---|
975 | #endif
|
---|
976 |
|
---|
977 | /** @def LOG_TO_COM
|
---|
978 | * Redirects the normal loging macros to the serial versions.
|
---|
979 | */
|
---|
980 |
|
---|
981 | /** @def LOG_NO_COM
|
---|
982 | * Disables all LogCom* macros.
|
---|
983 | */
|
---|
984 |
|
---|
985 | /** @def LogCom
|
---|
986 | * Generic logging to serial port.
|
---|
987 | */
|
---|
988 | #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
|
---|
989 | # define LogCom(a) RTLogComPrintf a
|
---|
990 | #else
|
---|
991 | # define LogCom(a) do { } while (0)
|
---|
992 | #endif
|
---|
993 |
|
---|
994 | /** @def LogComFlow
|
---|
995 | * Logging to serial port of execution flow.
|
---|
996 | */
|
---|
997 | #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
|
---|
998 | # define LogComFlow(a) RTLogComPrintf a
|
---|
999 | #else
|
---|
1000 | # define LogComFlow(a) do { } while (0)
|
---|
1001 | #endif
|
---|
1002 |
|
---|
1003 | #ifdef LOG_TO_COM
|
---|
1004 | # undef Log
|
---|
1005 | # define Log(a) LogCom(a)
|
---|
1006 | # undef LogFlow
|
---|
1007 | # define LogFlow(a) LogComFlow(a)
|
---|
1008 | #endif
|
---|
1009 |
|
---|
1010 | /** @} */
|
---|
1011 |
|
---|
1012 |
|
---|
1013 | /** @name Backdoor Logging
|
---|
1014 | * @{
|
---|
1015 | */
|
---|
1016 |
|
---|
1017 | #ifdef __DOXYGEN__
|
---|
1018 | # define LOG_TO_BACKDOOR
|
---|
1019 | # define LOG_NO_BACKDOOR
|
---|
1020 | #endif
|
---|
1021 |
|
---|
1022 | /** @def LOG_TO_BACKDOOR
|
---|
1023 | * Redirects the normal logging macros to the backdoor versions.
|
---|
1024 | */
|
---|
1025 |
|
---|
1026 | /** @def LOG_NO_BACKDOOR
|
---|
1027 | * Disables all LogBackdoor* macros.
|
---|
1028 | */
|
---|
1029 |
|
---|
1030 | /** @def LogBackdoor
|
---|
1031 | * Generic logging to the VBox backdoor via port I/O.
|
---|
1032 | */
|
---|
1033 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
1034 | # define LogBackdoor(a) RTLogBackdoorPrintf a
|
---|
1035 | #else
|
---|
1036 | # define LogBackdoor(a) do { } while (0)
|
---|
1037 | #endif
|
---|
1038 |
|
---|
1039 | /** @def LogBackdoorFlow
|
---|
1040 | * Logging of execution flow messages to the backdoor I/O port.
|
---|
1041 | */
|
---|
1042 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
1043 | # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
|
---|
1044 | #else
|
---|
1045 | # define LogBackdoorFlow(a) do { } while (0)
|
---|
1046 | #endif
|
---|
1047 |
|
---|
1048 | /** @def LogRelBackdoor
|
---|
1049 | * Release logging to the VBox backdoor via port I/O.
|
---|
1050 | */
|
---|
1051 | #if !defined(LOG_NO_BACKDOOR)
|
---|
1052 | # define LogRelBackdoor(a) RTLogBackdoorPrintf a
|
---|
1053 | #else
|
---|
1054 | # define LogRelBackdoor(a) do { } while (0)
|
---|
1055 | #endif
|
---|
1056 |
|
---|
1057 | #ifdef LOG_TO_BACKDOOR
|
---|
1058 | # undef Log
|
---|
1059 | # define Log(a) LogBackdoor(a)
|
---|
1060 | # undef LogFlow
|
---|
1061 | # define LogFlow(a) LogBackdoorFlow(a)
|
---|
1062 | # undef LogRel
|
---|
1063 | # define LogRel(a) LogRelBackdoor(a)
|
---|
1064 | #endif
|
---|
1065 |
|
---|
1066 | /** @} */
|
---|
1067 |
|
---|
1068 |
|
---|
1069 |
|
---|
1070 |
|
---|
1071 | /**
|
---|
1072 | * Gets the default logger instance.
|
---|
1073 | *
|
---|
1074 | * @returns Pointer to default logger instance.
|
---|
1075 | * @returns NULL if no default logger instance available.
|
---|
1076 | */
|
---|
1077 | RTDECL(PRTLOGGER) RTLogDefaultInstance(void);
|
---|
1078 |
|
---|
1079 | #ifdef IN_RING0
|
---|
1080 | /**
|
---|
1081 | * Changes the default logger instance for the current thread.
|
---|
1082 | *
|
---|
1083 | * @returns IPRT status code.
|
---|
1084 | * @param pLogger The logger instance. Pass NULL for deregistration.
|
---|
1085 | * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
|
---|
1086 | * all instances with this key will be deregistered. So in
|
---|
1087 | * order to only deregister the instance associated with the
|
---|
1088 | * current thread use 0.
|
---|
1089 | */
|
---|
1090 | RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
|
---|
1091 | #endif /* IN_RING0 */
|
---|
1092 |
|
---|
1093 |
|
---|
1094 | #ifdef LOG_ENABLED
|
---|
1095 | /** Internal worker function.
|
---|
1096 | * Don't call directly, use the LogIsItEnabled macro!
|
---|
1097 | */
|
---|
1098 | DECLINLINE(bool) LogIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
1099 | {
|
---|
1100 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogDefaultInstance();
|
---|
1101 | if (pLogger)
|
---|
1102 | {
|
---|
1103 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
1104 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
1105 | return true;
|
---|
1106 | }
|
---|
1107 | return false;
|
---|
1108 | }
|
---|
1109 | #endif
|
---|
1110 |
|
---|
1111 |
|
---|
1112 | #ifndef IN_GC
|
---|
1113 | /**
|
---|
1114 | * Creates the default logger instance for a iprt users.
|
---|
1115 | *
|
---|
1116 | * Any user of the logging features will need to implement
|
---|
1117 | * this or use the generic dummy.
|
---|
1118 | *
|
---|
1119 | * @returns Pointer to the logger instance.
|
---|
1120 | */
|
---|
1121 | RTDECL(PRTLOGGER) RTLogDefaultInit(void);
|
---|
1122 |
|
---|
1123 | /**
|
---|
1124 | * Create a logger instance.
|
---|
1125 | *
|
---|
1126 | * @returns iprt status code.
|
---|
1127 | *
|
---|
1128 | * @param ppLogger Where to store the logger instance.
|
---|
1129 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1130 | * @param pszGroupSettings The initial group settings.
|
---|
1131 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
1132 | * @param cGroups Number of groups in the array.
|
---|
1133 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
1134 | * logger instance.
|
---|
1135 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
1136 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
1137 | * @param ... Format arguments.
|
---|
1138 | */
|
---|
1139 | RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
1140 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1141 | RTUINT fDestFlags, const char *pszFilenameFmt, ...);
|
---|
1142 |
|
---|
1143 | /**
|
---|
1144 | * Create a logger instance.
|
---|
1145 | *
|
---|
1146 | * @returns iprt status code.
|
---|
1147 | *
|
---|
1148 | * @param ppLogger Where to store the logger instance.
|
---|
1149 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1150 | * @param pszGroupSettings The initial group settings.
|
---|
1151 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
1152 | * @param cGroups Number of groups in the array.
|
---|
1153 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
1154 | * logger instance.
|
---|
1155 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
1156 | * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
|
---|
1157 | * @param cchErrorMsg The size of the error message buffer.
|
---|
1158 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
1159 | * @param ... Format arguments.
|
---|
1160 | */
|
---|
1161 | RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
1162 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1163 | RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
|
---|
1164 |
|
---|
1165 | /**
|
---|
1166 | * Create a logger instance.
|
---|
1167 | *
|
---|
1168 | * @returns iprt status code.
|
---|
1169 | *
|
---|
1170 | * @param ppLogger Where to store the logger instance.
|
---|
1171 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1172 | * @param pszGroupSettings The initial group settings.
|
---|
1173 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
1174 | * @param cGroups Number of groups in the array.
|
---|
1175 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
1176 | * logger instance.
|
---|
1177 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
1178 | * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
|
---|
1179 | * @param cchErrorMsg The size of the error message buffer.
|
---|
1180 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
1181 | * @param args Format arguments.
|
---|
1182 | */
|
---|
1183 | RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
1184 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
1185 | RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
|
---|
1186 |
|
---|
1187 | /**
|
---|
1188 | * Create a logger instance for singled threaded ring-0 usage.
|
---|
1189 | *
|
---|
1190 | * @returns iprt status code.
|
---|
1191 | *
|
---|
1192 | * @param pLogger Where to create the logger instance.
|
---|
1193 | * @param cbLogger The amount of memory available for the logger instance.
|
---|
1194 | * @param pfnLogger Pointer to logger wrapper function for the clone.
|
---|
1195 | * @param pfnFlush Pointer to flush function for the clone.
|
---|
1196 | * @param fFlags Logger instance flags for the clone, a combination of the RTLOGFLAGS_* values.
|
---|
1197 | * @param fDestFlags The destination flags.
|
---|
1198 | */
|
---|
1199 | RTDECL(int) RTLogCreateForR0(PRTLOGGER pLogger, size_t cbLogger, PFNRTLOGGER pfnLogger, PFNRTLOGFLUSH pfnFlush, RTUINT fFlags, RTUINT fDestFlags);
|
---|
1200 |
|
---|
1201 | /**
|
---|
1202 | * Destroys a logger instance.
|
---|
1203 | *
|
---|
1204 | * The instance is flushed and all output destinations closed (where applicable).
|
---|
1205 | *
|
---|
1206 | * @returns iprt status code.
|
---|
1207 | * @param pLogger The logger instance which close destroyed.
|
---|
1208 | */
|
---|
1209 | RTDECL(int) RTLogDestroy(PRTLOGGER pLogger);
|
---|
1210 |
|
---|
1211 | /**
|
---|
1212 | * Create a logger instance clone for GC usage.
|
---|
1213 | *
|
---|
1214 | * @returns iprt status code.
|
---|
1215 | *
|
---|
1216 | * @param pLogger The logger instance to be cloned.
|
---|
1217 | * @param pLoggerGC Where to create the GC logger instance.
|
---|
1218 | * @param cbLoggerGC Amount of memory allocated to for the GC logger instance clone.
|
---|
1219 | * @param pfnLoggerGCPtr Pointer to logger wrapper function for this instance (GC Ptr).
|
---|
1220 | * @param pfnFlushGCPtr Pointer to flush function (GC Ptr).
|
---|
1221 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
1222 | */
|
---|
1223 | RTDECL(int) RTLogCloneGC(PRTLOGGER pLogger, PRTLOGGERGC pLoggerGC, size_t cbLoggerGC,
|
---|
1224 | RTGCPTR pfnLoggerGCPtr, RTGCPTR pfnFlushGCPtr, RTUINT fFlags);
|
---|
1225 |
|
---|
1226 | /**
|
---|
1227 | * Flushes a GC logger instance to a HC logger.
|
---|
1228 | *
|
---|
1229 | * @returns iprt status code.
|
---|
1230 | * @param pLogger The HC logger instance to flush pLoggerGC to.
|
---|
1231 | * If NULL the default logger is used.
|
---|
1232 | * @param pLoggerGC The GC logger instance to flush.
|
---|
1233 | */
|
---|
1234 | RTDECL(void) RTLogFlushGC(PRTLOGGER pLogger, PRTLOGGERGC pLoggerGC);
|
---|
1235 |
|
---|
1236 | /**
|
---|
1237 | * Flushes the buffer in one logger instance onto another logger.
|
---|
1238 | *
|
---|
1239 | * @returns iprt status code.
|
---|
1240 | *
|
---|
1241 | * @param pSrcLogger The logger instance to flush.
|
---|
1242 | * @param pDstLogger The logger instance to flush onto.
|
---|
1243 | * If NULL the default logger will be used.
|
---|
1244 | */
|
---|
1245 | RTDECL(void) RTLogFlushToLogger(PRTLOGGER pSrcLogger, PRTLOGGER pDstLogger);
|
---|
1246 |
|
---|
1247 | /**
|
---|
1248 | * Copies the group settings and flags from logger instance to another.
|
---|
1249 | *
|
---|
1250 | * @returns IPRT status code.
|
---|
1251 | * @param pDstLogger The destination logger instance.
|
---|
1252 | * @param pSrcLogger The source logger instance. If NULL the default one is used.
|
---|
1253 | * @param fFlagsOr OR mask for the flags.
|
---|
1254 | * @param fFlagsAnd AND mask for the flags.
|
---|
1255 | */
|
---|
1256 | RTDECL(int) RTLogCopyGroupsAndFlags(PRTLOGGER pDstLogger, PCRTLOGGER pSrcLogger, unsigned fFlagsOr, unsigned fFlagsAnd);
|
---|
1257 |
|
---|
1258 | /**
|
---|
1259 | * Updates the group settings for the logger instance using the specified
|
---|
1260 | * specification string.
|
---|
1261 | *
|
---|
1262 | * @returns iprt status code.
|
---|
1263 | * Failures can safely be ignored.
|
---|
1264 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1265 | * @param pszVar Value to parse.
|
---|
1266 | */
|
---|
1267 | RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger, const char *pszVar);
|
---|
1268 | #endif /* !IN_GC */
|
---|
1269 |
|
---|
1270 | /**
|
---|
1271 | * Updates the flags for the logger instance using the specified
|
---|
1272 | * specification string.
|
---|
1273 | *
|
---|
1274 | * @returns iprt status code.
|
---|
1275 | * Failures can safely be ignored.
|
---|
1276 | * @param pLogger Logger instance (NULL for default logger).
|
---|
1277 | * @param pszVar Value to parse.
|
---|
1278 | */
|
---|
1279 | RTDECL(int) RTLogFlags(PRTLOGGER pLogger, const char *pszVar);
|
---|
1280 |
|
---|
1281 | /**
|
---|
1282 | * Flushes the specified logger.
|
---|
1283 | *
|
---|
1284 | * @param pLogger The logger instance to flush.
|
---|
1285 | * If NULL the default instance is used. The default instance
|
---|
1286 | * will not be initialized by this call.
|
---|
1287 | */
|
---|
1288 | RTDECL(void) RTLogFlush(PRTLOGGER pLogger);
|
---|
1289 |
|
---|
1290 | /**
|
---|
1291 | * Write to a logger instance.
|
---|
1292 | *
|
---|
1293 | * @param pLogger Pointer to logger instance.
|
---|
1294 | * @param pvCallerRet Ignored.
|
---|
1295 | * @param pszFormat Format string.
|
---|
1296 | * @param ... Format arguments.
|
---|
1297 | */
|
---|
1298 | RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...);
|
---|
1299 |
|
---|
1300 | /**
|
---|
1301 | * Write to a logger instance.
|
---|
1302 | *
|
---|
1303 | * @param pLogger Pointer to logger instance.
|
---|
1304 | * @param pszFormat Format string.
|
---|
1305 | * @param args Format arguments.
|
---|
1306 | */
|
---|
1307 | RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args);
|
---|
1308 |
|
---|
1309 | /**
|
---|
1310 | * Write to a logger instance.
|
---|
1311 | *
|
---|
1312 | * This function will check whether the instance, group and flags makes up a
|
---|
1313 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1314 | *
|
---|
1315 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
1316 | * @param fFlags The logging flags.
|
---|
1317 | * @param iGroup The group.
|
---|
1318 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
1319 | * only for internal usage!
|
---|
1320 | * @param pszFormat Format string.
|
---|
1321 | * @param ... Format arguments.
|
---|
1322 | * @remark This is a worker function of LogIt.
|
---|
1323 | */
|
---|
1324 | RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
1325 |
|
---|
1326 | /**
|
---|
1327 | * Write to a logger instance.
|
---|
1328 | *
|
---|
1329 | * This function will check whether the instance, group and flags makes up a
|
---|
1330 | * logging kind which is currently enabled before writing anything to the log.
|
---|
1331 | *
|
---|
1332 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
1333 | * @param fFlags The logging flags.
|
---|
1334 | * @param iGroup The group.
|
---|
1335 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
1336 | * only for internal usage!
|
---|
1337 | * @param pszFormat Format string.
|
---|
1338 | * @param args Format arguments.
|
---|
1339 | */
|
---|
1340 | RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
1341 |
|
---|
1342 | /**
|
---|
1343 | * printf like function for writing to the default log.
|
---|
1344 | *
|
---|
1345 | * @param pszFormat Printf like format string.
|
---|
1346 | * @param ... Optional arguments as specified in pszFormat.
|
---|
1347 | *
|
---|
1348 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1349 | */
|
---|
1350 | RTDECL(void) RTLogPrintf(const char *pszFormat, ...);
|
---|
1351 |
|
---|
1352 | /**
|
---|
1353 | * vprintf like function for writing to the default log.
|
---|
1354 | *
|
---|
1355 | * @param pszFormat Printf like format string.
|
---|
1356 | * @param args Optional arguments as specified in pszFormat.
|
---|
1357 | *
|
---|
1358 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
1359 | */
|
---|
1360 | RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list args);
|
---|
1361 |
|
---|
1362 |
|
---|
1363 | #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
|
---|
1364 | #define DECLARED_FNRTSTROUTPUT
|
---|
1365 | /**
|
---|
1366 | * Output callback.
|
---|
1367 | *
|
---|
1368 | * @returns number of bytes written.
|
---|
1369 | * @param pvArg User argument.
|
---|
1370 | * @param pachChars Pointer to an array of utf-8 characters.
|
---|
1371 | * @param cbChars Number of bytes in the character array pointed to by pachChars.
|
---|
1372 | */
|
---|
1373 | typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg, const char *pachChars, size_t cbChars);
|
---|
1374 | /** Pointer to callback function. */
|
---|
1375 | typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
|
---|
1376 | #endif
|
---|
1377 |
|
---|
1378 | /**
|
---|
1379 | * Partial vsprintf worker implementation.
|
---|
1380 | *
|
---|
1381 | * @returns number of bytes formatted.
|
---|
1382 | * @param pfnOutput Output worker.
|
---|
1383 | * Called in two ways. Normally with a string an it's length.
|
---|
1384 | * For termination, it's called with NULL for string, 0 for length.
|
---|
1385 | * @param pvArg Argument to output worker.
|
---|
1386 | * @param pszFormat Format string.
|
---|
1387 | * @param args Argument list.
|
---|
1388 | */
|
---|
1389 | RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args);
|
---|
1390 |
|
---|
1391 | /**
|
---|
1392 | * Write log buffer to COM port.
|
---|
1393 | *
|
---|
1394 | * @param pach Pointer to the buffer to write.
|
---|
1395 | * @param cb Number of bytes to write.
|
---|
1396 | */
|
---|
1397 | RTDECL(void) RTLogWriteCom(const char *pach, size_t cb);
|
---|
1398 |
|
---|
1399 | /**
|
---|
1400 | * Prints a formatted string to the serial port used for logging.
|
---|
1401 | *
|
---|
1402 | * @returns Number of bytes written.
|
---|
1403 | * @param pszFormat Format string.
|
---|
1404 | * @param ... Optional arguments specified in the format string.
|
---|
1405 | */
|
---|
1406 | RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...);
|
---|
1407 |
|
---|
1408 | /**
|
---|
1409 | * Prints a formatted string to the serial port used for logging.
|
---|
1410 | *
|
---|
1411 | * @returns Number of bytes written.
|
---|
1412 | * @param pszFormat Format string.
|
---|
1413 | * @param args Optional arguments specified in the format string.
|
---|
1414 | */
|
---|
1415 | RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args);
|
---|
1416 |
|
---|
1417 |
|
---|
1418 | #if 0 /* not implemented yet */
|
---|
1419 |
|
---|
1420 | /** Indicates that the semaphores shall be used to notify the other
|
---|
1421 | * part about buffer changes. */
|
---|
1422 | #define LOGHOOKBUFFER_FLAGS_SEMAPHORED 1
|
---|
1423 |
|
---|
1424 | /**
|
---|
1425 | * Log Hook Buffer.
|
---|
1426 | * Use to commuicate between the logger and a log consumer.
|
---|
1427 | */
|
---|
1428 | typedef struct RTLOGHOOKBUFFER
|
---|
1429 | {
|
---|
1430 | /** Write pointer. */
|
---|
1431 | volatile void *pvWrite;
|
---|
1432 | /** Read pointer. */
|
---|
1433 | volatile void *pvRead;
|
---|
1434 | /** Buffer start. */
|
---|
1435 | void *pvStart;
|
---|
1436 | /** Buffer end (exclusive). */
|
---|
1437 | void *pvEnd;
|
---|
1438 | /** Signaling semaphore used by the writer to wait on a full buffer.
|
---|
1439 | * Only used when indicated in flags. */
|
---|
1440 | void *pvSemWriter;
|
---|
1441 | /** Signaling semaphore used by the read to wait on an empty buffer.
|
---|
1442 | * Only used when indicated in flags. */
|
---|
1443 | void *pvSemReader;
|
---|
1444 | /** Buffer flags. Current reserved and set to zero. */
|
---|
1445 | volatile unsigned fFlags;
|
---|
1446 | } RTLOGHOOKBUFFER;
|
---|
1447 | /** Pointer to a log hook buffer. */
|
---|
1448 | typedef RTLOGHOOKBUFFER *PRTLOGHOOKBUFFER;
|
---|
1449 |
|
---|
1450 |
|
---|
1451 | /**
|
---|
1452 | * Register a logging hook.
|
---|
1453 | *
|
---|
1454 | * This type of logging hooks are expecting different threads acting
|
---|
1455 | * producer and consumer. They share a circular buffer which have two
|
---|
1456 | * pointers one for each end. When the buffer is full there are two
|
---|
1457 | * alternatives (indicated by a buffer flag), either wait for the
|
---|
1458 | * consumer to get it's job done, or to write a generic message saying
|
---|
1459 | * buffer overflow.
|
---|
1460 | *
|
---|
1461 | * Since the waiting would need a signal semaphore, we'll skip that for now.
|
---|
1462 | *
|
---|
1463 | * @returns iprt status code.
|
---|
1464 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
1465 | */
|
---|
1466 | RTDECL(int) RTLogRegisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
1467 |
|
---|
1468 | /**
|
---|
1469 | * Deregister a logging hook registerd with RTLogRegisterHook().
|
---|
1470 | *
|
---|
1471 | * @returns iprt status code.
|
---|
1472 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
1473 | */
|
---|
1474 | RTDECL(int) RTLogDeregisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
1475 |
|
---|
1476 | #endif /* not implemented yet */
|
---|
1477 |
|
---|
1478 |
|
---|
1479 |
|
---|
1480 | /**
|
---|
1481 | * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
|
---|
1482 | *
|
---|
1483 | * @param pach What to write.
|
---|
1484 | * @param cb How much to write.
|
---|
1485 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
1486 | */
|
---|
1487 | RTDECL(void) RTLogWriteDebugger(const char *pach, size_t cb);
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | * Write log buffer to a user defined output stream (RTLOGDEST_USER).
|
---|
1491 | *
|
---|
1492 | * @param pach What to write.
|
---|
1493 | * @param cb How much to write.
|
---|
1494 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
1495 | */
|
---|
1496 | RTDECL(void) RTLogWriteUser(const char *pach, size_t cb);
|
---|
1497 |
|
---|
1498 | /**
|
---|
1499 | * Write log buffer to stdout (RTLOGDEST_STDOUT).
|
---|
1500 | *
|
---|
1501 | * @param pach What to write.
|
---|
1502 | * @param cb How much to write.
|
---|
1503 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
1504 | */
|
---|
1505 | RTDECL(void) RTLogWriteStdOut(const char *pach, size_t cb);
|
---|
1506 |
|
---|
1507 | /**
|
---|
1508 | * Write log buffer to stdout (RTLOGDEST_STDERR).
|
---|
1509 | *
|
---|
1510 | * @param pach What to write.
|
---|
1511 | * @param cb How much to write.
|
---|
1512 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
1513 | */
|
---|
1514 | RTDECL(void) RTLogWriteStdErr(const char *pach, size_t cb);
|
---|
1515 |
|
---|
1516 | #ifdef VBOX
|
---|
1517 |
|
---|
1518 | /**
|
---|
1519 | * Prints a formatted string to the backdoor port.
|
---|
1520 | *
|
---|
1521 | * @returns Number of bytes written.
|
---|
1522 | * @param pszFormat Format string.
|
---|
1523 | * @param ... Optional arguments specified in the format string.
|
---|
1524 | */
|
---|
1525 | RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...);
|
---|
1526 |
|
---|
1527 | /**
|
---|
1528 | * Prints a formatted string to the backdoor port.
|
---|
1529 | *
|
---|
1530 | * @returns Number of bytes written.
|
---|
1531 | * @param pszFormat Format string.
|
---|
1532 | * @param args Optional arguments specified in the format string.
|
---|
1533 | */
|
---|
1534 | RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args);
|
---|
1535 |
|
---|
1536 | #endif /* VBOX */
|
---|
1537 |
|
---|
1538 | __END_DECLS
|
---|
1539 |
|
---|
1540 | /** @} */
|
---|
1541 |
|
---|
1542 | #endif
|
---|
1543 |
|
---|