6 * Copyright (C) 2006-2017 Oracle Corporation
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.
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.
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.
29 #include <iprt/cdefs.h>
30 #include <iprt/types.h>
31 #include <iprt/stdarg.h>
35 /** @defgroup grp_rt_log RTLog - Logging
41 * IPRT Logging Groups.
42 * (Remember to update RT_LOGGROUP_NAMES!)
44 * @remark It should be pretty obvious, but just to have
45 * mentioned it, the values are sorted alphabetically (using the
46 * english alphabet) except for _DEFAULT which is always first.
48 * If anyone might be wondering what the alphabet looks like:
49 * a b c d e f g h i j k l m n o p q r s t u v w x y z
51 typedef enum RTLOGGROUP
53 /** Default logging group. */
72 RTLOGGROUP_FIRST_USER
= 32
75 /** @def RT_LOGGROUP_NAMES
76 * IPRT Logging group names.
78 * Must correspond 100% to RTLOGGROUP!
79 * Don't forget commas!
81 * @remark It should be pretty obvious, but just to have
82 * mentioned it, the values are sorted alphabetically (using the
83 * english alphabet) except for _DEFAULT which is always first.
85 * If anyone might be wondering what the alphabet looks like:
86 * 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
88 #define RT_LOGGROUP_NAMES \
124 * Active logging group.
127 # define LOG_GROUP RTLOGGROUP_DEFAULT
131 * You can use this to specify you desired way of printing __PRETTY_FUNCTION__
132 * if you dislike the default one.
135 # define LOG_FN_FMT "%Rfn"
139 # error "LOG_INSTANCE is no longer supported."
141 #ifdef LOG_REL_INSTANCE
142 # error "LOG_REL_INSTANCE is no longer supported."
145 /** Logger structure. */
147 typedef struct RTLOGGERRC RTLOGGER
;
149 typedef struct RTLOGGER RTLOGGER
;
151 /** Pointer to logger structure. */
152 typedef RTLOGGER
*PRTLOGGER
;
153 /** Pointer to const logger structure. */
154 typedef const RTLOGGER
*PCRTLOGGER
;
157 /** Guest context logger structure. */
158 typedef struct RTLOGGERRC RTLOGGERRC
;
159 /** Pointer to guest context logger structure. */
160 typedef RTLOGGERRC
*PRTLOGGERRC
;
161 /** Pointer to const guest context logger structure. */
162 typedef const RTLOGGERRC
*PCRTLOGGERRC
;
168 * Used for signalling the log header/footer callback what to do.
170 typedef enum RTLOGPHASE
172 /** Begin of the logging. */
173 RTLOGPHASE_BEGIN
= 0,
174 /** End of the logging. */
176 /** Before rotating the log file. */
177 RTLOGPHASE_PREROTATE
,
178 /** After rotating the log file. */
179 RTLOGPHASE_POSTROTATE
,
180 /** 32-bit type blow up hack. */
181 RTLOGPHASE_32BIT_HACK
= 0x7fffffff
188 * @param pszFormat Format string.
189 * @param ... Optional arguments as specified in the format string.
191 typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
192 /** Pointer to logger function. */
193 typedef FNRTLOGGER
*PFNRTLOGGER
;
198 * @param pLogger Pointer to the logger instance which is to be flushed.
200 typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger
);
201 /** Pointer to flush function. */
202 typedef FNRTLOGFLUSH
*PFNRTLOGFLUSH
;
207 * @param pLogger Pointer to the logger instance which is to be flushed.
209 typedef DECLCALLBACK(void) FNRTLOGFLUSHGC(PRTLOGGERRC pLogger
);
210 /** Pointer to logger function. */
211 typedef RCPTRTYPE(FNRTLOGFLUSHGC
*) PFNRTLOGFLUSHGC
;
214 * Header/footer message callback.
216 * @param pLogger Pointer to the logger instance.
217 * @param pszFormat Format string.
218 * @param ... Optional arguments specified in the format string.
220 typedef DECLCALLBACK(void) FNRTLOGPHASEMSG(PRTLOGGER pLogger
, const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(2, 3);
221 /** Pointer to header/footer message callback function. */
222 typedef FNRTLOGPHASEMSG
*PFNRTLOGPHASEMSG
;
225 * Log file header/footer callback.
227 * @param pLogger Pointer to the logger instance.
228 * @param enmLogPhase Indicates at what time the callback is invoked.
229 * @param pfnLogPhaseMsg Callback for writing the header/footer (RTLogPrintf
230 * and others are out of bounds).
232 typedef DECLCALLBACK(void) FNRTLOGPHASE(PRTLOGGER pLogger
, RTLOGPHASE enmLogPhase
, PFNRTLOGPHASEMSG pfnLogPhaseMsg
);
233 /** Pointer to log header/footer callback function. */
234 typedef FNRTLOGPHASE
*PFNRTLOGPHASE
;
237 * Custom log prefix callback.
240 * @returns The number of chars written.
242 * @param pLogger Pointer to the logger instance.
243 * @param pchBuf Output buffer pointer.
244 * No need to terminate the output.
245 * @param cchBuf The size of the output buffer.
246 * @param pvUser The user argument.
248 typedef DECLCALLBACK(size_t) FNRTLOGPREFIX(PRTLOGGER pLogger
, char *pchBuf
, size_t cchBuf
, void *pvUser
);
249 /** Pointer to prefix callback function. */
250 typedef FNRTLOGPREFIX
*PFNRTLOGPREFIX
;
255 * Logger instance structure for raw-mode context (RC).
259 /** Pointer to temporary scratch buffer.
260 * This is used to format the log messages. */
261 char achScratch
[32768];
262 /** Current scratch buffer position. */
264 /** This is set if a prefix is pending. */
267 /** Pointer to the logger function.
268 * This is actually pointer to a wrapper which will push a pointer to the
269 * instance pointer onto the stack before jumping to the real logger function.
270 * A very unfortunate hack to work around the missing variadic macro support in C++. */
271 RCPTRTYPE(PFNRTLOGGER
) pfnLogger
;
272 /** Pointer to the flush function. */
273 PFNRTLOGFLUSHGC pfnFlush
;
274 /** Magic number (RTLOGGERRC_MAGIC). */
276 /** Logger instance flags - RTLOGFLAGS. */
278 /** Number of groups in the afGroups member. */
280 /** Group flags array - RTLOGGRPFLAGS.
281 * This member have variable length and may extend way beyond
282 * the declared size of 1 entry. */
283 uint32_t afGroups
[1];
286 /** RTLOGGERRC::u32Magic value. (John Rogers Searle) */
287 #define RTLOGGERRC_MAGIC 0x19320731
293 /** Pointer to internal logger bits. */
294 typedef struct RTLOGGERINTERNAL
*PRTLOGGERINTERNAL
;
297 * Logger instance structure.
301 /** Pointer to temporary scratch buffer.
302 * This is used to format the log messages. */
303 char achScratch
[49152];
304 /** Current scratch buffer position. */
308 /** Logger instance flags - RTLOGFLAGS. */
310 /** Destination flags - RTLOGDEST. */
312 /** Pointer to the internal bits of the logger.
313 * (The memory is allocated in the same block as RTLOGGER.) */
314 PRTLOGGERINTERNAL pInt
;
315 /** Pointer to the logger function (used in non-C99 mode only).
317 * This is actually pointer to a wrapper which will push a pointer to the
318 * instance pointer onto the stack before jumping to the real logger function.
319 * A very unfortunate hack to work around the missing variadic macro
320 * support in older C++/C standards. (The memory is allocated using
321 * RTMemExecAlloc(), except for agnostic R0 code.) */
322 PFNRTLOGGER pfnLogger
;
323 /** Number of groups in the afGroups and papszGroups members. */
325 /** Group flags array - RTLOGGRPFLAGS.
326 * This member have variable length and may extend way beyond
327 * the declared size of 1 entry. */
328 uint32_t afGroups
[1];
331 /** RTLOGGER::u32Magic value. (Avram Noam Chomsky) */
332 # define RTLOGGER_MAGIC UINT32_C(0x19281207)
340 typedef enum RTLOGFLAGS
342 /** The logger instance is disabled for normal output. */
343 RTLOGFLAGS_DISABLED
= 0x00000001,
344 /** The logger instance is using buffered output. */
345 RTLOGFLAGS_BUFFERED
= 0x00000002,
346 /** The logger instance expands LF to CR/LF. */
347 RTLOGFLAGS_USECRLF
= 0x00000010,
348 /** Append to the log destination where applicable. */
349 RTLOGFLAGS_APPEND
= 0x00000020,
350 /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
351 RTLOGFLAGS_REL_TS
= 0x00000040,
352 /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
353 RTLOGFLAGS_DECIMAL_TS
= 0x00000080,
354 /** Open the file in write through mode. */
355 RTLOGFLAGS_WRITE_THROUGH
= 0x00000100,
356 /** Flush the file to disk when flushing the buffer. */
357 RTLOGFLAGS_FLUSH
= 0x00000200,
358 /** Restrict the number of log entries per group. */
359 RTLOGFLAGS_RESTRICT_GROUPS
= 0x00000400,
360 /** New lines should be prefixed with the write and read lock counts. */
361 RTLOGFLAGS_PREFIX_LOCK_COUNTS
= 0x00008000,
362 /** New lines should be prefixed with the CPU id (ApicID on intel/amd). */
363 RTLOGFLAGS_PREFIX_CPUID
= 0x00010000,
364 /** New lines should be prefixed with the native process id. */
365 RTLOGFLAGS_PREFIX_PID
= 0x00020000,
366 /** New lines should be prefixed with group flag number causing the output. */
367 RTLOGFLAGS_PREFIX_FLAG_NO
= 0x00040000,
368 /** New lines should be prefixed with group flag name causing the output. */
369 RTLOGFLAGS_PREFIX_FLAG
= 0x00080000,
370 /** New lines should be prefixed with group number. */
371 RTLOGFLAGS_PREFIX_GROUP_NO
= 0x00100000,
372 /** New lines should be prefixed with group name. */
373 RTLOGFLAGS_PREFIX_GROUP
= 0x00200000,
374 /** New lines should be prefixed with the native thread id. */
375 RTLOGFLAGS_PREFIX_TID
= 0x00400000,
376 /** New lines should be prefixed with thread name. */
377 RTLOGFLAGS_PREFIX_THREAD
= 0x00800000,
378 /** New lines should be prefixed with data from a custom callback. */
379 RTLOGFLAGS_PREFIX_CUSTOM
= 0x01000000,
380 /** New lines should be prefixed with formatted timestamp since program start. */
381 RTLOGFLAGS_PREFIX_TIME_PROG
= 0x04000000,
382 /** New lines should be prefixed with formatted timestamp (UCT). */
383 RTLOGFLAGS_PREFIX_TIME
= 0x08000000,
384 /** New lines should be prefixed with milliseconds since program start. */
385 RTLOGFLAGS_PREFIX_MS_PROG
= 0x10000000,
386 /** New lines should be prefixed with timestamp. */
387 RTLOGFLAGS_PREFIX_TSC
= 0x20000000,
388 /** New lines should be prefixed with timestamp. */
389 RTLOGFLAGS_PREFIX_TS
= 0x40000000,
390 /** The prefix mask. */
391 RTLOGFLAGS_PREFIX_MASK
= 0x7dff8000
395 * Logger per group flags.
397 * @remarks We only use the lower 16 bits here. We'll be combining it with the
398 * group number in a few places.
400 typedef enum RTLOGGRPFLAGS
403 RTLOGGRPFLAGS_ENABLED
= 0x0001,
405 RTLOGGRPFLAGS_FLOW
= 0x0002,
406 /** Warnings logging. */
407 RTLOGGRPFLAGS_WARN
= 0x0004,
408 /* 0x0008 for later. */
409 /** Level 1 logging. */
410 RTLOGGRPFLAGS_LEVEL_1
= 0x0010,
411 /** Level 2 logging. */
412 RTLOGGRPFLAGS_LEVEL_2
= 0x0020,
413 /** Level 3 logging. */
414 RTLOGGRPFLAGS_LEVEL_3
= 0x0040,
415 /** Level 4 logging. */
416 RTLOGGRPFLAGS_LEVEL_4
= 0x0080,
417 /** Level 5 logging. */
418 RTLOGGRPFLAGS_LEVEL_5
= 0x0100,
419 /** Level 6 logging. */
420 RTLOGGRPFLAGS_LEVEL_6
= 0x0200,
421 /** Level 7 logging. */
422 RTLOGGRPFLAGS_LEVEL_7
= 0x0400,
423 /** Level 8 logging. */
424 RTLOGGRPFLAGS_LEVEL_8
= 0x0800,
425 /** Level 9 logging. */
426 RTLOGGRPFLAGS_LEVEL_9
= 0x1000,
427 /** Level 10 logging. */
428 RTLOGGRPFLAGS_LEVEL_10
= 0x2000,
429 /** Level 11 logging. */
430 RTLOGGRPFLAGS_LEVEL_11
= 0x4000,
431 /** Level 12 logging. */
432 RTLOGGRPFLAGS_LEVEL_12
= 0x8000,
434 /** Restrict the number of log entries. */
435 RTLOGGRPFLAGS_RESTRICT
= 0x40000000,
436 /** Blow up the type. */
437 RTLOGGRPFLAGS_32BIT_HACK
= 0x7fffffff
441 * Logger destination types and flags.
443 typedef enum RTLOGDEST
446 RTLOGDEST_FILE
= 0x00000001,
447 /** Log to stdout. */
448 RTLOGDEST_STDOUT
= 0x00000002,
449 /** Log to stderr. */
450 RTLOGDEST_STDERR
= 0x00000004,
451 /** Log to debugger (win32 only). */
452 RTLOGDEST_DEBUGGER
= 0x00000008,
453 /** Log to com port. */
454 RTLOGDEST_COM
= 0x00000010,
455 /** Log a memory ring buffer. */
456 RTLOGDEST_RINGBUF
= 0x00000020,
457 /** Open files with no deny (share read, write, delete) on Windows. */
458 RTLOGDEST_F_NO_DENY
= 0x00010000,
459 /** Delay opening the log file, logging to the buffer untill
460 * RTLogClearFileDelayFlag is called. */
461 RTLOGDEST_F_DELAY_FILE
= 0x00020000,
462 /** Just a dummy flag to be used when no other flag applies. */
463 RTLOGDEST_DUMMY
= 0x20000000,
464 /** Log to a user defined output stream. */
465 RTLOGDEST_USER
= 0x40000000
469 RTDECL(void) RTLogPrintfEx(void *pvInstance
, unsigned fFlags
, unsigned iGroup
,
470 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
473 #ifdef DOXYGEN_RUNNING
474 # define LOG_DISABLED
476 # define LOG_ENABLE_FLOW
479 /** @def LOG_DISABLED
480 * Use this compile time define to disable all logging macros. It can
481 * be overridden for each of the logging macros by the LOG_ENABLE*
482 * compile time defines.
486 * Use this compile time define to enable logging when not in debug mode
487 * or LOG_DISABLED is set.
488 * This will enabled Log() only.
491 /** @def LOG_ENABLE_FLOW
492 * Use this compile time define to enable flow logging when not in
493 * debug mode or LOG_DISABLED is defined.
494 * This will enable LogFlow() only.
498 * Determine whether logging is enabled and forcefully normalize the indicators.
500 #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
507 # define LOG_DISABLED
512 * Governs the use of variadic macros.
515 # if defined(RT_ARCH_AMD64) || defined(RT_OS_DARWIN) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
521 /** @name Macros for checking whether a log level is enabled.
523 /** @def LogIsItEnabled
524 * Checks whether the specified logging group is enabled or not.
527 # define LogIsItEnabled(a_fFlags, a_iGroup) ( RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
529 # define LogIsItEnabled(a_fFlags, a_iGroup) (false)
532 /** @def LogIsEnabled
533 * Checks whether level 1 logging is enabled.
535 #define LogIsEnabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
537 /** @def LogIs2Enabled
538 * Checks whether level 2 logging is enabled.
540 #define LogIs2Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
542 /** @def LogIs3Enabled
543 * Checks whether level 3 logging is enabled.
545 #define LogIs3Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
547 /** @def LogIs4Enabled
548 * Checks whether level 4 logging is enabled.
550 #define LogIs4Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
552 /** @def LogIs5Enabled
553 * Checks whether level 5 logging is enabled.
555 #define LogIs5Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
557 /** @def LogIs6Enabled
558 * Checks whether level 6 logging is enabled.
560 #define LogIs6Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
562 /** @def LogIs7Enabled
563 * Checks whether level 7 logging is enabled.
565 #define LogIs7Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
567 /** @def LogIs8Enabled
568 * Checks whether level 8 logging is enabled.
570 #define LogIs8Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
572 /** @def LogIs9Enabled
573 * Checks whether level 9 logging is enabled.
575 #define LogIs9Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
577 /** @def LogIs10Enabled
578 * Checks whether level 10 logging is enabled.
580 #define LogIs10Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
582 /** @def LogIs11Enabled
583 * Checks whether level 11 logging is enabled.
585 #define LogIs11Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
587 /** @def LogIs12Enabled
588 * Checks whether level 12 logging is enabled.
590 #define LogIs12Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
592 /** @def LogIsFlowEnabled
593 * Checks whether execution flow logging is enabled.
595 #define LogIsFlowEnabled() LogIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
597 /** @def LogIsWarnEnabled
598 * Checks whether execution flow logging is enabled.
600 #define LogIsWarnEnabled() LogIsItEnabled(RTLOGGRPFLAGS_WARN, LOG_GROUP)
605 * Write to specific logger if group enabled.
608 # if defined(LOG_USE_C99)
609 # define _LogRemoveParentheseis(...) __VA_ARGS__
610 # define _LogIt(a_fFlags, a_iGroup, ...) \
613 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
614 if (RT_LIKELY(!LogIt_pLogger)) \
617 RTLogLoggerEx(LogIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
619 # define LogIt(a_fFlags, a_iGroup, fmtargs) _LogIt(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
620 # define _LogItAlways(a_fFlags, a_iGroup, ...) RTLogLoggerEx(NULL, a_fFlags, UINT32_MAX, __VA_ARGS__)
621 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) _LogItAlways(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
622 /** @todo invent a flag or something for skipping the group check so we can pass iGroup. LogItAlways. */
624 # define LogIt(a_fFlags, a_iGroup, fmtargs) \
627 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
628 if (RT_LIKELY(!LogIt_pLogger)) \
632 LogIt_pLogger->pfnLogger fmtargs; \
635 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) \
638 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(0, UINT16_MAX)); \
640 LogIt_pLogger->pfnLogger fmtargs; \
644 # define LogIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
645 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) do { } while (0)
646 # if defined(LOG_USE_C99)
647 # define _LogRemoveParentheseis(...) __VA_ARGS__
648 # define _LogIt(a_fFlags, a_iGroup, ...) do { } while (0)
649 # define _LogItAlways(a_fFlags, a_iGroup, ...) do { } while (0)
654 /** @name Basic logging macros
657 * Level 1 logging that works regardless of the group settings.
659 #define LogAlways(a) LogItAlways(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
664 #define Log(a) LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
669 #define Log2(a) LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
674 #define Log3(a) LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
679 #define Log4(a) LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
684 #define Log5(a) LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
689 #define Log6(a) LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
694 #define Log7(a) LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
699 #define Log8(a) LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
704 #define Log9(a) LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
709 #define Log10(a) LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
714 #define Log11(a) LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
719 #define Log12(a) LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
722 * Logging of execution flow.
724 #define LogFlow(a) LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
727 * Logging of warnings.
729 #define LogWarn(a) LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
733 /** @name Logging macros prefixing the current function name.
736 * Level 1 logging inside C/C++ functions.
738 * Prepends the given log message with the function name followed by a
739 * semicolon and space.
741 * @param a Log message in format <tt>("string\n" [, args])</tt>.
744 # define LogFunc(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
746 # define LogFunc(a) do { Log((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
750 * Level 2 logging inside C/C++ functions.
752 * Prepends the given log message with the function name followed by a
753 * semicolon and space.
755 * @param a Log message in format <tt>("string\n" [, args])</tt>.
758 # define Log2Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
760 # define Log2Func(a) do { Log2((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
764 * Level 3 logging inside C/C++ functions.
766 * Prepends the given log message with the function name followed by a
767 * semicolon and space.
769 * @param a Log message in format <tt>("string\n" [, args])</tt>.
772 # define Log3Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
774 # define Log3Func(a) do { Log3((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
778 * Level 4 logging inside C/C++ functions.
780 * Prepends the given log message with the function name followed by a
781 * semicolon and space.
783 * @param a Log message in format <tt>("string\n" [, args])</tt>.
786 # define Log4Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
788 # define Log4Func(a) do { Log4((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
792 * Level 5 logging inside C/C++ functions.
794 * Prepends the given log message with the function name followed by a
795 * semicolon and space.
797 * @param a Log message in format <tt>("string\n" [, args])</tt>.
800 # define Log5Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
802 # define Log5Func(a) do { Log5((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
806 * Level 6 logging inside C/C++ functions.
808 * Prepends the given log message with the function name followed by a
809 * semicolon and space.
811 * @param a Log message in format <tt>("string\n" [, args])</tt>.
814 # define Log6Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
816 # define Log6Func(a) do { Log6((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
820 * Level 7 logging inside C/C++ functions.
822 * Prepends the given log message with the function name followed by a
823 * semicolon and space.
825 * @param a Log message in format <tt>("string\n" [, args])</tt>.
828 # define Log7Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
830 # define Log7Func(a) do { Log7((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
834 * Level 8 logging inside C/C++ functions.
836 * Prepends the given log message with the function name followed by a
837 * semicolon and space.
839 * @param a Log message in format <tt>("string\n" [, args])</tt>.
842 # define Log8Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
844 # define Log8Func(a) do { Log8((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
848 * Level 9 logging inside C/C++ functions.
850 * Prepends the given log message with the function name followed by a
851 * semicolon and space.
853 * @param a Log message in format <tt>("string\n" [, args])</tt>.
856 # define Log9Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
858 # define Log9Func(a) do { Log9((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
862 * Level 10 logging inside C/C++ functions.
864 * Prepends the given log message with the function name followed by a
865 * semicolon and space.
867 * @param a Log message in format <tt>("string\n" [, args])</tt>.
870 # define Log10Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
872 # define Log10Func(a) do { Log10((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
876 * Level 11 logging inside C/C++ functions.
878 * Prepends the given log message with the function name followed by a
879 * semicolon and space.
881 * @param a Log message in format <tt>("string\n" [, args])</tt>.
884 # define Log11Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
886 # define Log11Func(a) do { Log11((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
890 * Level 12 logging inside C/C++ functions.
892 * Prepends the given log message with the function name followed by a
893 * semicolon and space.
895 * @param a Log message in format <tt>("string\n" [, args])</tt>.
898 # define Log12Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
900 # define Log12Func(a) do { Log12((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
904 * Macro to log the execution flow inside C/C++ functions.
906 * Prepends the given log message with the function name followed by
907 * a semicolon and space.
909 * @param a Log message in format <tt>("string\n" [, args])</tt>.
912 # define LogFlowFunc(a) \
913 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
915 # define LogFlowFunc(a) \
916 do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
920 * Macro to log a warning inside C/C++ functions.
922 * Prepends the given log message with the function name followed by
923 * a semicolon and space.
925 * @param a Log message in format <tt>("string\n" [, args])</tt>.
928 # define LogWarnFunc(a) \
929 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
931 # define LogWarnFunc(a) \
932 do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
937 /** @name Logging macros prefixing the this pointer value and method name.
941 * Level 1 logging inside a C++ non-static method, with object pointer and
942 * method name prefixed to the given message.
943 * @param a Log message in format <tt>("string\n" [, args])</tt>.
946 # define LogThisFunc(a) \
947 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
949 # define LogThisFunc(a) do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
952 /** @def Log2ThisFunc
953 * Level 2 logging inside a C++ non-static method, with object pointer and
954 * method name prefixed to the given message.
955 * @param a Log message in format <tt>("string\n" [, args])</tt>.
958 # define Log2ThisFunc(a) \
959 _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
961 # define Log2ThisFunc(a) do { Log2(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log2(a); } while (0)
964 /** @def Log3ThisFunc
965 * Level 3 logging inside a C++ non-static method, with object pointer and
966 * method name prefixed to the given message.
967 * @param a Log message in format <tt>("string\n" [, args])</tt>.
970 # define Log3ThisFunc(a) \
971 _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
973 # define Log3ThisFunc(a) do { Log3(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log3(a); } while (0)
976 /** @def Log4ThisFunc
977 * Level 4 logging inside a C++ non-static method, with object pointer and
978 * method name prefixed to the given message.
979 * @param a Log message in format <tt>("string\n" [, args])</tt>.
982 # define Log4ThisFunc(a) \
983 _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
985 # define Log4ThisFunc(a) do { Log4(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log4(a); } while (0)
988 /** @def Log5ThisFunc
989 * Level 5 logging inside a C++ non-static method, with object pointer and
990 * method name prefixed to the given message.
991 * @param a Log message in format <tt>("string\n" [, args])</tt>.
994 # define Log5ThisFunc(a) \
995 _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
997 # define Log5ThisFunc(a) do { Log5(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log5(a); } while (0)
1000 /** @def Log6ThisFunc
1001 * Level 6 logging inside a C++ non-static method, with object pointer and
1002 * method name prefixed to the given message.
1003 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1006 # define Log6ThisFunc(a) \
1007 _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1009 # define Log6ThisFunc(a) do { Log6(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log6(a); } while (0)
1012 /** @def Log7ThisFunc
1013 * Level 7 logging inside a C++ non-static method, with object pointer and
1014 * method name prefixed to the given message.
1015 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1018 # define Log7ThisFunc(a) \
1019 _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1021 # define Log7ThisFunc(a) do { Log7(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log7(a); } while (0)
1024 /** @def Log8ThisFunc
1025 * Level 8 logging inside a C++ non-static method, with object pointer and
1026 * method name prefixed to the given message.
1027 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1030 # define Log8ThisFunc(a) \
1031 _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1033 # define Log8ThisFunc(a) do { Log8(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log8(a); } while (0)
1036 /** @def Log9ThisFunc
1037 * Level 9 logging inside a C++ non-static method, with object pointer and
1038 * method name prefixed to the given message.
1039 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1042 # define Log9ThisFunc(a) \
1043 _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1045 # define Log9ThisFunc(a) do { Log9(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log9(a); } while (0)
1048 /** @def Log10ThisFunc
1049 * Level 10 logging inside a C++ non-static method, with object pointer and
1050 * method name prefixed to the given message.
1051 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1054 # define Log10ThisFunc(a) \
1055 _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1057 # define Log10ThisFunc(a) do { Log10(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log10(a); } while (0)
1060 /** @def Log11ThisFunc
1061 * Level 11 logging inside a C++ non-static method, with object pointer and
1062 * method name prefixed to the given message.
1063 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1066 # define Log11ThisFunc(a) \
1067 _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1069 # define Log11ThisFunc(a) do { Log11(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log11(a); } while (0)
1072 /** @def Log12ThisFunc
1073 * Level 12 logging inside a C++ non-static method, with object pointer and
1074 * method name prefixed to the given message.
1075 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1078 # define Log12ThisFunc(a) \
1079 _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1081 # define Log12ThisFunc(a) do { Log12(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log12(a); } while (0)
1084 /** @def LogFlowThisFunc
1085 * Flow level logging inside a C++ non-static method, with object pointer and
1086 * method name prefixed to the given message.
1087 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1090 # define LogFlowThisFunc(a) \
1091 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1093 # define LogFlowThisFunc(a) do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
1096 /** @def LogWarnThisFunc
1097 * Warning level logging inside a C++ non-static method, with object pointer and
1098 * method name prefixed to the given message.
1099 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1102 # define LogWarnThisFunc(a) \
1103 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1105 # define LogWarnThisFunc(a) do { LogWarn(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogWarn(a); } while (0)
1110 /** @name Misc Logging Macros
1113 /** @def Log1Warning
1114 * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
1116 * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
1118 #if defined(LOG_USE_C99)
1119 # define Log1Warning(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a )
1121 # define Log1Warning(a) do { Log(("WARNING! ")); Log(a); } while (0)
1124 /** @def Log1WarningFunc
1125 * The same as LogWarning(), but prepents the log message with the function name.
1127 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1130 # define Log1WarningFunc(a) \
1131 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1133 # define Log1WarningFunc(a) \
1134 do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0)
1137 /** @def Log1WarningThisFunc
1138 * The same as LogWarningFunc() but for class functions (methods): the resulting
1139 * log line is additionally prepended with a hex value of |this| pointer.
1141 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1144 # define Log1WarningThisFunc(a) \
1145 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1147 # define Log1WarningThisFunc(a) \
1148 do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
1152 /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1153 #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
1155 /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */
1156 #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
1158 /** Shortcut to |LogFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1159 #define LogFlowFuncLeaveRC(rc) LogFlowFunc(("LEAVE: %Rrc\n", (rc)))
1161 /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1162 #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
1164 /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1165 #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
1168 /** @def LogObjRefCnt
1169 * Helper macro to print the current reference count of the given COM object
1172 * @param pObj Pointer to the object in question (must be a pointer to an
1173 * IUnknown subclass or simply define COM-style AddRef() and
1174 * Release() methods)
1176 #define LogObjRefCnt(pObj) \
1178 if (LogIsFlowEnabled()) \
1180 int cRefsForLog = (pObj)->AddRef(); \
1181 LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), cRefsForLog - 1)); \
1182 (pObj)->Release(); \
1189 /** @name Passing Function Call Position When Logging.
1191 * This is a little bit ugly as we have to omit the comma before the
1192 * position parameters so that we don't inccur any overhead in non-logging
1193 * builds (!defined(LOG_ENABLED).
1196 /** Source position for passing to a function call. */
1198 # define RTLOG_COMMA_SRC_POS , __FILE__, __LINE__, __PRETTY_FUNCTION__
1200 # define RTLOG_COMMA_SRC_POS RT_NOTHING
1202 /** Source position declaration. */
1204 # define RTLOG_COMMA_SRC_POS_DECL , const char *pszFile, unsigned iLine, const char *pszFunction
1206 # define RTLOG_COMMA_SRC_POS_DECL RT_NOTHING
1208 /** Source position arguments. */
1210 # define RTLOG_COMMA_SRC_POS_ARGS , pszFile, iLine, pszFunction
1212 # define RTLOG_COMMA_SRC_POS_ARGS RT_NOTHING
1214 /** Applies NOREF() to the source position arguments. */
1216 # define RTLOG_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
1218 # define RTLOG_SRC_POS_NOREF() do { } while (0)
1224 /** @name Release Logging
1228 #ifdef DOXYGEN_RUNNING
1229 # define RTLOG_REL_DISABLED
1230 # define RTLOG_REL_ENABLED
1233 /** @def RTLOG_REL_DISABLED
1234 * Use this compile time define to disable all release logging
1238 /** @def RTLOG_REL_ENABLED
1239 * Use this compile time define to override RTLOG_REL_DISABLE.
1243 * Determine whether release logging is enabled and forcefully normalize the indicators.
1245 #if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED)
1246 # undef RTLOG_REL_DISABLED
1247 # undef RTLOG_REL_ENABLED
1248 # define RTLOG_REL_ENABLED
1250 # undef RTLOG_REL_ENABLED
1251 # undef RTLOG_REL_DISABLED
1252 # define RTLOG_REL_DISABLED
1255 /** @name Macros for checking whether a release log level is enabled.
1257 /** @def LogRelIsItEnabled
1258 * Checks whether the specified release logging group is enabled or not.
1260 #define LogRelIsItEnabled(a_fFlags, a_iGroup) ( RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
1262 /** @def LogRelIsEnabled
1263 * Checks whether level 1 release logging is enabled.
1265 #define LogRelIsEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
1267 /** @def LogRelIs2Enabled
1268 * Checks whether level 2 release logging is enabled.
1270 #define LogRelIs2Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
1272 /** @def LogRelIs3Enabled
1273 * Checks whether level 3 release logging is enabled.
1275 #define LogRelIs3Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
1277 /** @def LogRelIs4Enabled
1278 * Checks whether level 4 release logging is enabled.
1280 #define LogRelIs4Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
1282 /** @def LogRelIs5Enabled
1283 * Checks whether level 5 release logging is enabled.
1285 #define LogRelIs5Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
1287 /** @def LogRelIs6Enabled
1288 * Checks whether level 6 release logging is enabled.
1290 #define LogRelIs6Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
1292 /** @def LogRelIs7Enabled
1293 * Checks whether level 7 release logging is enabled.
1295 #define LogRelIs7Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
1297 /** @def LogRelIs8Enabled
1298 * Checks whether level 8 release logging is enabled.
1300 #define LogRelIs8Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
1302 /** @def LogRelIs2Enabled
1303 * Checks whether level 9 release logging is enabled.
1305 #define LogRelIs9Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
1307 /** @def LogRelIs10Enabled
1308 * Checks whether level 10 release logging is enabled.
1310 #define LogRelIs10Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
1312 /** @def LogRelIs11Enabled
1313 * Checks whether level 10 release logging is enabled.
1315 #define LogRelIs11Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
1317 /** @def LogRelIs12Enabled
1318 * Checks whether level 12 release logging is enabled.
1320 #define LogRelIs12Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
1322 /** @def LogRelIsFlowEnabled
1323 * Checks whether execution flow release logging is enabled.
1325 #define LogRelIsFlowEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1327 /** @def LogRelIsWarnEnabled
1328 * Checks whether warning level release logging is enabled.
1330 #define LogRelIsWarnEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1335 * Write to specific logger if group enabled.
1337 /** @def LogRelItLikely
1338 * Write to specific logger if group enabled, assuming it likely it is enabled.
1340 /** @def LogRelMaxIt
1341 * Write to specific logger if group enabled and at less than a_cMax messages
1342 * have hit the log. Uses a static variable to count.
1344 #ifdef RTLOG_REL_ENABLED
1345 # if defined(LOG_USE_C99)
1346 # define _LogRelRemoveParentheseis(...) __VA_ARGS__
1347 # define _LogRelIt(a_fFlags, a_iGroup, ...) \
1350 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1351 if (RT_LIKELY(!LogRelIt_pLogger)) \
1354 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1355 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1357 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1358 _LogRelIt(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1359 # define _LogRelItLikely(a_fFlags, a_iGroup, ...) \
1362 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1363 if (LogRelIt_pLogger) \
1364 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1365 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1367 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1368 _LogRelItLikely(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1369 # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) \
1372 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1373 if (LogRelIt_pLogger) \
1375 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1376 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1378 s_LogRelMaxIt_cLogged++; \
1379 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1382 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1384 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1385 _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1387 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1390 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1391 if (LogRelIt_pLogger) \
1393 LogRelIt_pLogger->pfnLogger fmtargs; \
1395 LogIt(a_fFlags, a_iGroup, fmtargs); \
1397 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1400 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1401 if (RT_LIKELY(!LogRelIt_pLogger)) \
1405 LogRelIt_pLogger->pfnLogger fmtargs; \
1407 LogIt(a_fFlags, a_iGroup, fmtargs); \
1409 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1412 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1413 if (LogRelIt_pLogger) \
1415 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1416 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1418 s_LogRelMaxIt_cLogged++; \
1419 LogRelIt_pLogger->pfnLogger fmtargs; \
1422 LogIt(a_fFlags, a_iGroup, fmtargs); \
1425 #else /* !RTLOG_REL_ENABLED */
1426 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1427 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1428 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) do { } while (0)
1429 # if defined(LOG_USE_C99)
1430 # define _LogRelRemoveParentheseis(...) __VA_ARGS__
1431 # define _LogRelIt(a_fFlags, a_iGroup, ...) do { } while (0)
1432 # define _LogRelItLikely(a_fFlags, a_iGroup, ...) do { } while (0)
1433 # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) do { } while (0)
1435 #endif /* !RTLOG_REL_ENABLED */
1438 /** @name Basic release logging macros
1441 * Level 1 release logging.
1443 #define LogRel(a) LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1446 * Level 2 release logging.
1448 #define LogRel2(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1451 * Level 3 release logging.
1453 #define LogRel3(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1456 * Level 4 release logging.
1458 #define LogRel4(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1461 * Level 5 release logging.
1463 #define LogRel5(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1466 * Level 6 release logging.
1468 #define LogRel6(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1471 * Level 7 release logging.
1473 #define LogRel7(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1476 * Level 8 release logging.
1478 #define LogRel8(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1481 * Level 9 release logging.
1483 #define LogRel9(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1486 * Level 10 release logging.
1488 #define LogRel10(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1491 * Level 11 release logging.
1493 #define LogRel11(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1496 * Level 12 release logging.
1498 #define LogRel12(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1501 * Logging of execution flow.
1503 #define LogRelFlow(a) LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1506 * Warning level release logging.
1508 #define LogRelWarn(a) LogRelIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
1513 /** @name Basic release logging macros with local max
1516 * Level 1 release logging with a max number of log entries.
1518 #define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1521 * Level 2 release logging with a max number of log entries.
1523 #define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1526 * Level 3 release logging with a max number of log entries.
1528 #define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1531 * Level 4 release logging with a max number of log entries.
1533 #define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1536 * Level 5 release logging with a max number of log entries.
1538 #define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1541 * Level 6 release logging with a max number of log entries.
1543 #define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1546 * Level 7 release logging with a max number of log entries.
1548 #define LogRelMax7(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1551 * Level 8 release logging with a max number of log entries.
1553 #define LogRelMax8(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1556 * Level 9 release logging with a max number of log entries.
1558 #define LogRelMax9(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1560 /** @def LogRelMax10
1561 * Level 10 release logging with a max number of log entries.
1563 #define LogRelMax10(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1565 /** @def LogRelMax11
1566 * Level 11 release logging with a max number of log entries.
1568 #define LogRelMax11(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1570 /** @def LogRelMax12
1571 * Level 12 release logging with a max number of log entries.
1573 #define LogRelMax12(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1575 /** @def LogRelMaxFlow
1576 * Logging of execution flow with a max number of log entries.
1578 #define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1582 /** @name Release logging macros prefixing the current function name.
1586 * Release logging. Prepends the given log message with the function name
1587 * followed by a semicolon and space.
1590 # define LogRelFunc(a) \
1591 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1593 # define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1596 /** @def LogRelFlowFunc
1597 * Release logging. Macro to log the execution flow inside C/C++ functions.
1599 * Prepends the given log message with the function name followed by
1600 * a semicolon and space.
1602 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1605 # define LogRelFlowFunc(a) _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1607 # define LogRelFlowFunc(a) do { LogRelFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1610 /** @def LogRelMaxFunc
1611 * Release logging. Prepends the given log message with the function name
1612 * followed by a semicolon and space.
1615 # define LogRelMaxFunc(a_cMax, a) \
1616 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1618 # define LogRelMaxFunc(a_cMax, a) \
1619 do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1622 /** @def LogRelMaxFlowFunc
1623 * Release logging. Macro to log the execution flow inside C/C++ functions.
1625 * Prepends the given log message with the function name followed by
1626 * a semicolon and space.
1628 * @param a_cMax Max number of times this should hit the log.
1629 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1632 # define LogRelMaxFlowFunc(a_cMax, a) \
1633 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1635 # define LogRelMaxFlowFunc(a_cMax, a) \
1636 do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0)
1642 /** @name Release Logging macros prefixing the this pointer value and method name.
1645 /** @def LogRelThisFunc
1646 * The same as LogRelFunc but for class functions (methods): the resulting log
1647 * line is additionally prepended with a hex value of |this| pointer.
1650 # define LogRelThisFunc(a) \
1651 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1653 # define LogRelThisFunc(a) \
1654 do { LogRel(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1657 /** @def LogRelMaxThisFunc
1658 * The same as LogRelFunc but for class functions (methods): the resulting log
1659 * line is additionally prepended with a hex value of |this| pointer.
1660 * @param a_cMax Max number of times this should hit the log.
1661 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1664 # define LogRelMaxThisFunc(a_cMax, a) \
1665 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1667 # define LogRelMaxThisFunc(a_cMax, a) \
1668 do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1671 /** @def LogRelFlowThisFunc
1672 * The same as LogRelFlowFunc but for class functions (methods): the resulting
1673 * log line is additionally prepended with a hex value of |this| pointer.
1676 # define LogRelFlowThisFunc(a) \
1677 _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1679 # define LogRelFlowThisFunc(a) do { LogRelFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1683 /** Shortcut to |LogRelFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1684 #define LogRelFlowFuncEnter() LogRelFlowFunc(("ENTER\n"))
1686 /** Shortcut to |LogRelFlowFunc ("LEAVE\n")|, marks the end of the function. */
1687 #define LogRelFlowFuncLeave() LogRelFlowFunc(("LEAVE\n"))
1689 /** Shortcut to |LogRelFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1690 #define LogRelFlowFuncLeaveRC(rc) LogRelFlowFunc(("LEAVE: %Rrc\n", (rc)))
1692 /** Shortcut to |LogRelFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1693 #define LogRelFlowThisFuncEnter() LogRelFlowThisFunc(("ENTER\n"))
1695 /** Shortcut to |LogRelFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1696 #define LogRelFlowThisFuncLeave() LogRelFlowThisFunc(("LEAVE\n"))
1703 * Sets the default release logger instance.
1705 * @returns The old default instance.
1706 * @param pLogger The new default release logger instance.
1708 RTDECL(PRTLOGGER
) RTLogRelSetDefaultInstance(PRTLOGGER pLogger
);
1712 * Gets the default release logger instance.
1714 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1716 RTDECL(PRTLOGGER
) RTLogRelGetDefaultInstance(void);
1719 * Gets the default release logger instance.
1721 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1722 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1725 RTDECL(PRTLOGGER
) RTLogRelGetDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1728 * Write to a logger instance, defaulting to the release one.
1730 * This function will check whether the instance, group and flags makes up a
1731 * logging kind which is currently enabled before writing anything to the log.
1733 * @param pLogger Pointer to logger instance.
1734 * @param fFlags The logging flags.
1735 * @param iGroup The group.
1736 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1737 * only for internal usage!
1738 * @param pszFormat Format string.
1739 * @param ... Format arguments.
1740 * @remark This is a worker function for LogRelIt.
1742 RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
1743 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
1746 * Write to a logger instance, defaulting to the release one.
1748 * This function will check whether the instance, group and flags makes up a
1749 * logging kind which is currently enabled before writing anything to the log.
1751 * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
1752 * @param fFlags The logging flags.
1753 * @param iGroup The group.
1754 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1755 * only for internal usage!
1756 * @param pszFormat Format string.
1757 * @param args Format arguments.
1759 RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
1760 const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(4, 0);
1763 * printf like function for writing to the default release log.
1765 * @param pszFormat Printf like format string.
1766 * @param ... Optional arguments as specified in pszFormat.
1768 * @remark The API doesn't support formatting of floating point numbers at the moment.
1770 RTDECL(void) RTLogRelPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
1773 * vprintf like function for writing to the default release log.
1775 * @param pszFormat Printf like format string.
1776 * @param args Optional arguments as specified in pszFormat.
1778 * @remark The API doesn't support formatting of floating point numbers at the moment.
1780 RTDECL(void) RTLogRelPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);
1783 * Changes the buffering setting of the default release logger.
1785 * This can be used for optimizing longish logging sequences.
1787 * @returns The old state.
1788 * @param fBuffered The new state.
1790 RTDECL(bool) RTLogRelSetBuffering(bool fBuffered
);
1796 /** @name COM port logging
1800 #ifdef DOXYGEN_RUNNING
1806 * Redirects the normal logging macros to the serial versions.
1810 * Disables all LogCom* macros.
1814 * Generic logging to serial port.
1816 #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
1817 # define LogCom(a) RTLogComPrintf a
1819 # define LogCom(a) do { } while (0)
1823 * Logging to serial port of execution flow.
1825 #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
1826 # define LogComFlow(a) RTLogComPrintf a
1828 # define LogComFlow(a) do { } while (0)
1833 # define Log(a) LogCom(a)
1835 # define LogFlow(a) LogComFlow(a)
1841 /** @name Backdoor Logging
1845 #ifdef DOXYGEN_RUNNING
1846 # define LOG_TO_BACKDOOR
1847 # define LOG_NO_BACKDOOR
1850 /** @def LOG_TO_BACKDOOR
1851 * Redirects the normal logging macros to the backdoor versions.
1854 /** @def LOG_NO_BACKDOOR
1855 * Disables all LogBackdoor* macros.
1858 /** @def LogBackdoor
1859 * Generic logging to the VBox backdoor via port I/O.
1861 #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1862 # define LogBackdoor(a) RTLogBackdoorPrintf a
1864 # define LogBackdoor(a) do { } while (0)
1867 /** @def LogBackdoorFlow
1868 * Logging of execution flow messages to the backdoor I/O port.
1870 #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1871 # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
1873 # define LogBackdoorFlow(a) do { } while (0)
1876 /** @def LogRelBackdoor
1877 * Release logging to the VBox backdoor via port I/O.
1879 #if !defined(LOG_NO_BACKDOOR)
1880 # define LogRelBackdoor(a) RTLogBackdoorPrintf a
1882 # define LogRelBackdoor(a) do { } while (0)
1885 #ifdef LOG_TO_BACKDOOR
1887 # define Log(a) LogBackdoor(a)
1889 # define LogFlow(a) LogBackdoorFlow(a)
1891 # define LogRel(a) LogRelBackdoor(a)
1892 # if defined(LOG_USE_C99)
1894 # define _LogIt(a_fFlags, a_iGroup, ...) LogBackdoor((__VA_ARGS__))
1903 * Gets the default logger instance, creating it if necessary.
1905 * @returns Pointer to default logger instance if availble, otherwise NULL.
1907 RTDECL(PRTLOGGER
) RTLogDefaultInstance(void);
1910 * Gets the logger instance if enabled, creating it if necessary.
1912 * @returns Pointer to default logger instance, if group has the specified
1913 * flags enabled. Otherwise NULL is returned.
1914 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1917 RTDECL(PRTLOGGER
) RTLogDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1920 * Gets the default logger instance.
1922 * @returns Pointer to default logger instance if availble, otherwise NULL.
1924 RTDECL(PRTLOGGER
) RTLogGetDefaultInstance(void);
1927 * Gets the default logger instance if enabled.
1929 * @returns Pointer to default logger instance, if group has the specified
1930 * flags enabled. Otherwise NULL is returned.
1931 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1934 RTDECL(PRTLOGGER
) RTLogGetDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1938 * Sets the default logger instance.
1940 * @returns The old default instance.
1941 * @param pLogger The new default logger instance.
1943 RTDECL(PRTLOGGER
) RTLogSetDefaultInstance(PRTLOGGER pLogger
);
1948 * Changes the default logger instance for the current thread.
1950 * @returns IPRT status code.
1951 * @param pLogger The logger instance. Pass NULL for deregistration.
1952 * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
1953 * all instances with this key will be deregistered. So in
1954 * order to only deregister the instance associated with the
1955 * current thread use 0.
1957 RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger
, uintptr_t uKey
);
1958 #endif /* IN_RING0 */
1963 * Creates the default logger instance for a iprt users.
1965 * Any user of the logging features will need to implement
1966 * this or use the generic dummy.
1968 * @returns Pointer to the logger instance.
1970 RTDECL(PRTLOGGER
) RTLogDefaultInit(void);
1973 * Create a logger instance.
1975 * @returns iprt status code.
1977 * @param ppLogger Where to store the logger instance.
1978 * @param fFlags Logger instance flags, a combination of the
1979 * RTLOGFLAGS_* values.
1980 * @param pszGroupSettings The initial group settings.
1981 * @param pszEnvVarBase Base name for the environment variables for
1983 * @param cGroups Number of groups in the array.
1984 * @param papszGroups Pointer to array of groups. This must stick
1985 * around for the life of the logger instance.
1986 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
1987 * if pszFilenameFmt specified.
1988 * @param pszFilenameFmt Log filename format string. Standard
1990 * @param ... Format arguments.
1992 RTDECL(int) RTLogCreate(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
1993 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
1994 uint32_t fDestFlags
, const char *pszFilenameFmt
, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
1997 * Create a logger instance.
1999 * @returns iprt status code.
2001 * @param ppLogger Where to store the logger instance.
2002 * @param fFlags Logger instance flags, a combination of the
2003 * RTLOGFLAGS_* values.
2004 * @param pszGroupSettings The initial group settings.
2005 * @param pszEnvVarBase Base name for the environment variables for
2007 * @param cGroups Number of groups in the array.
2008 * @param papszGroups Pointer to array of groups. This must stick
2009 * around for the life of the logger instance.
2010 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2011 * if pszFilenameFmt specified.
2012 * @param pfnPhase Callback function for starting logging and for
2013 * ending or starting a new file for log history
2014 * rotation. NULL is OK.
2015 * @param cHistory Number of old log files to keep when performing
2016 * log history rotation. 0 means no history.
2017 * @param cbHistoryFileMax Maximum size of log file when performing
2018 * history rotation. 0 means no size limit.
2019 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2020 * performing history rotation, in seconds.
2021 * 0 means time limit.
2022 * @param pErrInfo Where to return extended error information.
2024 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
2025 * @param ... Format arguments.
2027 RTDECL(int) RTLogCreateEx(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
2028 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
2029 uint32_t fDestFlags
, PFNRTLOGPHASE pfnPhase
, uint32_t cHistory
,
2030 uint64_t cbHistoryFileMax
, uint32_t cSecsHistoryTimeSlot
, PRTERRINFO pErrInfo
,
2031 const char *pszFilenameFmt
, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(13, 14);
2034 * Create a logger instance.
2036 * @returns iprt status code.
2038 * @param ppLogger Where to store the logger instance.
2039 * @param fFlags Logger instance flags, a combination of the
2040 * RTLOGFLAGS_* values.
2041 * @param pszGroupSettings The initial group settings.
2042 * @param pszEnvVarBase Base name for the environment variables for
2044 * @param cGroups Number of groups in the array.
2045 * @param papszGroups Pointer to array of groups. This must stick
2046 * around for the life of the logger instance.
2047 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2048 * if pszFilenameFmt specified.
2049 * @param pfnPhase Callback function for starting logging and for
2050 * ending or starting a new file for log history
2052 * @param cHistory Number of old log files to keep when performing
2053 * log history rotation. 0 means no history.
2054 * @param cbHistoryFileMax Maximum size of log file when performing
2055 * history rotation. 0 means no size limit.
2056 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2057 * performing history rotation, in seconds.
2058 * 0 means no time limit.
2059 * @param pErrInfo Where to return extended error information.
2061 * @param pszFilenameFmt Log filename format string. Standard
2063 * @param args Format arguments.
2065 RTDECL(int) RTLogCreateExV(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
2066 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
2067 uint32_t fDestFlags
, PFNRTLOGPHASE pfnPhase
, uint32_t cHistory
,
2068 uint64_t cbHistoryFileMax
, uint32_t cSecsHistoryTimeSlot
, PRTERRINFO pErrInfo
,
2069 const char *pszFilenameFmt
, va_list args
) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(13, 0);
2072 * Create a logger instance for singled threaded ring-0 usage.
2074 * @returns iprt status code.
2076 * @param pLogger Where to create the logger instance.
2077 * @param cbLogger The amount of memory available for the logger instance.
2078 * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
2079 * @param pfnLoggerR0Ptr Pointer to logger wrapper function.
2080 * @param pfnFlushR0Ptr Pointer to flush function.
2081 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
2082 * @param fDestFlags The destination flags.
2084 RTDECL(int) RTLogCreateForR0(PRTLOGGER pLogger
, size_t cbLogger
,
2085 RTR0PTR pLoggerR0Ptr
, RTR0PTR pfnLoggerR0Ptr
, RTR0PTR pfnFlushR0Ptr
,
2086 uint32_t fFlags
, uint32_t fDestFlags
);
2089 * Calculates the minimum size of a ring-0 logger instance.
2091 * @returns The minimum size.
2092 * @param cGroups The number of groups.
2093 * @param fFlags Relevant flags.
2095 RTDECL(size_t) RTLogCalcSizeForR0(uint32_t cGroups
, uint32_t fFlags
);
2098 * Destroys a logger instance.
2100 * The instance is flushed and all output destinations closed (where applicable).
2102 * @returns iprt status code.
2103 * @param pLogger The logger instance which close destroyed. NULL is fine.
2105 RTDECL(int) RTLogDestroy(PRTLOGGER pLogger
);
2108 * Create a logger instance clone for RC usage.
2110 * @returns iprt status code.
2112 * @param pLogger The logger instance to be cloned.
2113 * @param pLoggerRC Where to create the RC logger instance.
2114 * @param cbLoggerRC Amount of memory allocated to for the RC logger
2116 * @param pfnLoggerRCPtr Pointer to logger wrapper function for this
2117 * instance (RC Ptr).
2118 * @param pfnFlushRCPtr Pointer to flush function (RC Ptr).
2119 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
2121 RTDECL(int) RTLogCloneRC(PRTLOGGER pLogger
, PRTLOGGERRC pLoggerRC
, size_t cbLoggerRC
,
2122 RTRCPTR pfnLoggerRCPtr
, RTRCPTR pfnFlushRCPtr
, uint32_t fFlags
);
2125 * Flushes a RC logger instance to a R3 logger.
2127 * @returns iprt status code.
2128 * @param pLogger The R3 logger instance to flush pLoggerRC to. If NULL
2129 * the default logger is used.
2130 * @param pLoggerRC The RC logger instance to flush.
2132 RTDECL(void) RTLogFlushRC(PRTLOGGER pLogger
, PRTLOGGERRC pLoggerRC
);
2135 * Flushes the buffer in one logger instance onto another logger.
2137 * @returns iprt status code.
2139 * @param pSrcLogger The logger instance to flush.
2140 * @param pDstLogger The logger instance to flush onto.
2141 * If NULL the default logger will be used.
2143 RTDECL(void) RTLogFlushToLogger(PRTLOGGER pSrcLogger
, PRTLOGGER pDstLogger
);
2146 * Flushes a R0 logger instance to a R3 logger.
2148 * @returns iprt status code.
2149 * @param pLogger The R3 logger instance to flush pLoggerR0 to. If NULL
2150 * the default logger is used.
2151 * @param pLoggerR0 The R0 logger instance to flush.
2153 RTDECL(void) RTLogFlushR0(PRTLOGGER pLogger
, PRTLOGGER pLoggerR0
);
2156 * Sets the custom prefix callback.
2158 * @returns IPRT status code.
2159 * @param pLogger The logger instance.
2160 * @param pfnCallback The callback.
2161 * @param pvUser The user argument for the callback.
2163 RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger
, PFNRTLOGPREFIX pfnCallback
, void *pvUser
);
2166 * Same as RTLogSetCustomPrefixCallback for loggers created by
2169 * @returns IPRT status code.
2170 * @param pLogger The logger instance.
2171 * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
2172 * @param pfnCallbackR0Ptr The callback.
2173 * @param pvUserR0Ptr The user argument for the callback.
2175 RTDECL(int) RTLogSetCustomPrefixCallbackForR0(PRTLOGGER pLogger
, RTR0PTR pLoggerR0Ptr
,
2176 RTR0PTR pfnCallbackR0Ptr
, RTR0PTR pvUserR0Ptr
);
2179 * Copies the group settings and flags from logger instance to another.
2181 * @returns IPRT status code.
2182 * @param pDstLogger The destination logger instance.
2183 * @param pDstLoggerR0Ptr The ring-0 address corresponding to @a pDstLogger.
2184 * @param pSrcLogger The source logger instance. If NULL the default one is used.
2185 * @param fFlagsOr OR mask for the flags.
2186 * @param fFlagsAnd AND mask for the flags.
2188 RTDECL(int) RTLogCopyGroupsAndFlagsForR0(PRTLOGGER pDstLogger
, RTR0PTR pDstLoggerR0Ptr
,
2189 PCRTLOGGER pSrcLogger
, uint32_t fFlagsOr
, uint32_t fFlagsAnd
);
2192 * Get the current log group settings as a string.
2194 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2195 * @param pLogger Logger instance (NULL for default logger).
2196 * @param pszBuf The output buffer.
2197 * @param cchBuf The size of the output buffer. Must be greater
2200 RTDECL(int) RTLogGetGroupSettings(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2203 * Updates the group settings for the logger instance using the specified
2204 * specification string.
2206 * @returns iprt status code.
2207 * Failures can safely be ignored.
2208 * @param pLogger Logger instance (NULL for default logger).
2209 * @param pszValue Value to parse.
2211 RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger
, const char *pszValue
);
2215 * Updates the flags for the logger instance using the specified
2216 * specification string.
2218 * @returns iprt status code.
2219 * Failures can safely be ignored.
2220 * @param pLogger Logger instance (NULL for default logger).
2221 * @param pszValue Value to parse.
2223 RTDECL(int) RTLogFlags(PRTLOGGER pLogger
, const char *pszValue
);
2226 * Changes the buffering setting of the specified logger.
2228 * This can be used for optimizing longish logging sequences.
2230 * @returns The old state.
2231 * @param pLogger The logger instance (NULL is an alias for the
2233 * @param fBuffered The new state.
2235 RTDECL(bool) RTLogSetBuffering(PRTLOGGER pLogger
, bool fBuffered
);
2238 * Sets the max number of entries per group.
2240 * @returns Old restriction.
2242 * @param pLogger The logger instance (NULL is an alias for the
2244 * @param cMaxEntriesPerGroup The max number of entries per group.
2246 * @remarks Lowering the limit of an active logger may quietly mute groups.
2247 * Raising it may reactive already muted groups.
2249 RTDECL(uint32_t) RTLogSetGroupLimit(PRTLOGGER pLogger
, uint32_t cMaxEntriesPerGroup
);
2253 * Get the current log flags as a string.
2255 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2256 * @param pLogger Logger instance (NULL for default logger).
2257 * @param pszBuf The output buffer.
2258 * @param cchBuf The size of the output buffer. Must be greater
2261 RTDECL(int) RTLogGetFlags(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2264 * Updates the logger destination using the specified string.
2266 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2267 * @param pLogger Logger instance (NULL for default logger).
2268 * @param pszValue The value to parse.
2270 RTDECL(int) RTLogDestinations(PRTLOGGER pLogger
, char const *pszValue
);
2273 * Clear the file delay flag if set, opening the destination and flushing.
2275 * @returns IPRT status code.
2276 * @param pLogger Logger instance (NULL for default logger).
2277 * @param pszValue The value to parse.
2278 * @param pErrInfo Where to return extended error info. Optional.
2280 RTDECL(int) RTLogClearFileDelayFlag(PRTLOGGER pLogger
, PRTERRINFO pErrInfo
);
2283 * Get the current log destinations as a string.
2285 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2286 * @param pLogger Logger instance (NULL for default logger).
2287 * @param pszBuf The output buffer.
2288 * @param cchBuf The size of the output buffer. Must be greater
2291 RTDECL(int) RTLogGetDestinations(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2295 * Flushes the specified logger.
2297 * @param pLogger The logger instance to flush.
2298 * If NULL the default instance is used. The default instance
2299 * will not be initialized by this call.
2301 RTDECL(void) RTLogFlush(PRTLOGGER pLogger
);
2304 * Write to a logger instance.
2306 * @param pLogger Pointer to logger instance.
2307 * @param pvCallerRet Ignored.
2308 * @param pszFormat Format string.
2309 * @param ... Format arguments.
2311 RTDECL(void) RTLogLogger(PRTLOGGER pLogger
, void *pvCallerRet
, const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(3, 4);
2314 * Write to a logger instance.
2316 * @param pLogger Pointer to logger instance.
2317 * @param pszFormat Format string.
2318 * @param args Format arguments.
2320 RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger
, const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(3, 0);
2323 * Write to a logger instance.
2325 * This function will check whether the instance, group and flags makes up a
2326 * logging kind which is currently enabled before writing anything to the log.
2328 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2329 * @param fFlags The logging flags.
2330 * @param iGroup The group.
2331 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2332 * only for internal usage!
2333 * @param pszFormat Format string.
2334 * @param ... Format arguments.
2335 * @remark This is a worker function of LogIt.
2337 RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
2338 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
2341 * Write to a logger instance.
2343 * This function will check whether the instance, group and flags makes up a
2344 * logging kind which is currently enabled before writing anything to the log.
2346 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2347 * @param fFlags The logging flags.
2348 * @param iGroup The group.
2349 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2350 * only for internal usage!
2351 * @param pszFormat Format string.
2352 * @param args Format arguments.
2354 RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
2355 const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(4, 0);
2358 * printf like function for writing to the default log.
2360 * @param pszFormat Printf like format string.
2361 * @param ... Optional arguments as specified in pszFormat.
2363 * @remark The API doesn't support formatting of floating point numbers at the moment.
2365 RTDECL(void) RTLogPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2368 * vprintf like function for writing to the default log.
2370 * @param pszFormat Printf like format string.
2371 * @param va Optional arguments as specified in pszFormat.
2373 * @remark The API doesn't support formatting of floating point numbers at the moment.
2375 RTDECL(void) RTLogPrintfV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
2378 * Dumper vprintf-like function outputting to a logger.
2380 * @param pvUser Pointer to the logger instance to use, NULL for
2382 * @param pszFormat Format string.
2383 * @param va Format arguments.
2385 RTDECL(void) RTLogDumpPrintfV(void *pvUser
, const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(2, 0);
2388 #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
2389 #define DECLARED_FNRTSTROUTPUT
2393 * @returns number of bytes written.
2394 * @param pvArg User argument.
2395 * @param pachChars Pointer to an array of utf-8 characters.
2396 * @param cbChars Number of bytes in the character array pointed to by pachChars.
2398 typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg
, const char *pachChars
, size_t cbChars
);
2399 /** Pointer to callback function. */
2400 typedef FNRTSTROUTPUT
*PFNRTSTROUTPUT
;
2404 * Partial vsprintf worker implementation.
2406 * @returns number of bytes formatted.
2407 * @param pfnOutput Output worker.
2408 * Called in two ways. Normally with a string an it's length.
2409 * For termination, it's called with NULL for string, 0 for length.
2410 * @param pvArg Argument to output worker.
2411 * @param pszFormat Format string.
2412 * @param args Argument list.
2414 RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput
, void *pvArg
, const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(3, 0);
2417 * Write log buffer to COM port.
2419 * @param pach Pointer to the buffer to write.
2420 * @param cb Number of bytes to write.
2422 RTDECL(void) RTLogWriteCom(const char *pach
, size_t cb
);
2425 * Prints a formatted string to the serial port used for logging.
2427 * @returns Number of bytes written.
2428 * @param pszFormat Format string.
2429 * @param ... Optional arguments specified in the format string.
2431 RTDECL(size_t) RTLogComPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2434 * Prints a formatted string to the serial port used for logging.
2436 * @returns Number of bytes written.
2437 * @param pszFormat Format string.
2438 * @param args Optional arguments specified in the format string.
2440 RTDECL(size_t) RTLogComPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);
2443 #if 0 /* not implemented yet */
2445 /** Indicates that the semaphores shall be used to notify the other
2446 * part about buffer changes. */
2447 #define LOGHOOKBUFFER_FLAGS_SEMAPHORED 1
2451 * Use to communicate between the logger and a log consumer.
2453 typedef struct RTLOGHOOKBUFFER
2455 /** Write pointer. */
2456 volatile void *pvWrite
;
2457 /** Read pointer. */
2458 volatile void *pvRead
;
2459 /** Buffer start. */
2461 /** Buffer end (exclusive). */
2463 /** Signaling semaphore used by the writer to wait on a full buffer.
2464 * Only used when indicated in flags. */
2466 /** Signaling semaphore used by the read to wait on an empty buffer.
2467 * Only used when indicated in flags. */
2469 /** Buffer flags. Current reserved and set to zero. */
2470 volatile unsigned fFlags
;
2472 /** Pointer to a log hook buffer. */
2473 typedef RTLOGHOOKBUFFER
*PRTLOGHOOKBUFFER
;
2477 * Register a logging hook.
2479 * This type of logging hooks are expecting different threads acting
2480 * producer and consumer. They share a circular buffer which have two
2481 * pointers one for each end. When the buffer is full there are two
2482 * alternatives (indicated by a buffer flag), either wait for the
2483 * consumer to get it's job done, or to write a generic message saying
2486 * Since the waiting would need a signal semaphore, we'll skip that for now.
2488 * @returns iprt status code.
2489 * @param pBuffer Pointer to a logger hook buffer.
2491 RTDECL(int) RTLogRegisterHook(PRTLOGGER pLogger
, PRTLOGHOOKBUFFER pBuffer
);
2494 * Deregister a logging hook registered with RTLogRegisterHook().
2496 * @returns iprt status code.
2497 * @param pBuffer Pointer to a logger hook buffer.
2499 RTDECL(int) RTLogDeregisterHook(PRTLOGGER pLogger
, PRTLOGHOOKBUFFER pBuffer
);
2501 #endif /* not implemented yet */
2506 * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
2508 * @param pach What to write.
2509 * @param cb How much to write.
2510 * @remark When linking statically, this function can be replaced by defining your own.
2512 RTDECL(void) RTLogWriteDebugger(const char *pach
, size_t cb
);
2515 * Write log buffer to a user defined output stream (RTLOGDEST_USER).
2517 * @param pach What to write.
2518 * @param cb How much to write.
2519 * @remark When linking statically, this function can be replaced by defining your own.
2521 RTDECL(void) RTLogWriteUser(const char *pach
, size_t cb
);
2524 * Write log buffer to stdout (RTLOGDEST_STDOUT).
2526 * @param pach What to write.
2527 * @param cb How much to write.
2528 * @remark When linking statically, this function can be replaced by defining your own.
2530 RTDECL(void) RTLogWriteStdOut(const char *pach
, size_t cb
);
2533 * Write log buffer to stdout (RTLOGDEST_STDERR).
2535 * @param pach What to write.
2536 * @param cb How much to write.
2537 * @remark When linking statically, this function can be replaced by defining your own.
2539 RTDECL(void) RTLogWriteStdErr(const char *pach
, size_t cb
);
2544 * Prints a formatted string to the backdoor port.
2546 * @returns Number of bytes written.
2547 * @param pszFormat Format string.
2548 * @param ... Optional arguments specified in the format string.
2550 RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2553 * Prints a formatted string to the backdoor port.
2555 * @returns Number of bytes written.
2556 * @param pszFormat Format string.
2557 * @param args Optional arguments specified in the format string.
2559 RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);