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