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