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 /** Just a dummy flag to be used when no other flag applies. */
460 RTLOGDEST_DUMMY
= 0x20000000,
461 /** Log to a user defined output stream. */
462 RTLOGDEST_USER
= 0x40000000
466 RTDECL(void) RTLogPrintfEx(void *pvInstance
, unsigned fFlags
, unsigned iGroup
,
467 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
470 #ifdef DOXYGEN_RUNNING
471 # define LOG_DISABLED
473 # define LOG_ENABLE_FLOW
476 /** @def LOG_DISABLED
477 * Use this compile time define to disable all logging macros. It can
478 * be overridden for each of the logging macros by the LOG_ENABLE*
479 * compile time defines.
483 * Use this compile time define to enable logging when not in debug mode
484 * or LOG_DISABLED is set.
485 * This will enabled Log() only.
488 /** @def LOG_ENABLE_FLOW
489 * Use this compile time define to enable flow logging when not in
490 * debug mode or LOG_DISABLED is defined.
491 * This will enable LogFlow() only.
495 * Determine whether logging is enabled and forcefully normalize the indicators.
497 #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
504 # define LOG_DISABLED
509 * Governs the use of variadic macros.
512 # if defined(RT_ARCH_AMD64) || defined(RT_OS_DARWIN) || defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
518 /** @name Macros for checking whether a log level is enabled.
520 /** @def LogIsItEnabled
521 * Checks whether the specified logging group is enabled or not.
524 # define LogIsItEnabled(a_fFlags, a_iGroup) ( RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
526 # define LogIsItEnabled(a_fFlags, a_iGroup) (false)
529 /** @def LogIsEnabled
530 * Checks whether level 1 logging is enabled.
532 #define LogIsEnabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
534 /** @def LogIs2Enabled
535 * Checks whether level 2 logging is enabled.
537 #define LogIs2Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
539 /** @def LogIs3Enabled
540 * Checks whether level 3 logging is enabled.
542 #define LogIs3Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
544 /** @def LogIs4Enabled
545 * Checks whether level 4 logging is enabled.
547 #define LogIs4Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
549 /** @def LogIs5Enabled
550 * Checks whether level 5 logging is enabled.
552 #define LogIs5Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
554 /** @def LogIs6Enabled
555 * Checks whether level 6 logging is enabled.
557 #define LogIs6Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
559 /** @def LogIs7Enabled
560 * Checks whether level 7 logging is enabled.
562 #define LogIs7Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
564 /** @def LogIs8Enabled
565 * Checks whether level 8 logging is enabled.
567 #define LogIs8Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
569 /** @def LogIs9Enabled
570 * Checks whether level 9 logging is enabled.
572 #define LogIs9Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
574 /** @def LogIs10Enabled
575 * Checks whether level 10 logging is enabled.
577 #define LogIs10Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
579 /** @def LogIs11Enabled
580 * Checks whether level 11 logging is enabled.
582 #define LogIs11Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
584 /** @def LogIs12Enabled
585 * Checks whether level 12 logging is enabled.
587 #define LogIs12Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
589 /** @def LogIsFlowEnabled
590 * Checks whether execution flow logging is enabled.
592 #define LogIsFlowEnabled() LogIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
594 /** @def LogIsWarnEnabled
595 * Checks whether execution flow logging is enabled.
597 #define LogIsWarnEnabled() LogIsItEnabled(RTLOGGRPFLAGS_WARN, LOG_GROUP)
602 * Write to specific logger if group enabled.
605 # if defined(LOG_USE_C99)
606 # define _LogRemoveParentheseis(...) __VA_ARGS__
607 # define _LogIt(a_fFlags, a_iGroup, ...) \
610 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
611 if (RT_LIKELY(!LogIt_pLogger)) \
614 RTLogLoggerEx(LogIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
616 # define LogIt(a_fFlags, a_iGroup, fmtargs) _LogIt(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
617 # define _LogItAlways(a_fFlags, a_iGroup, ...) RTLogLoggerEx(NULL, a_fFlags, UINT32_MAX, __VA_ARGS__)
618 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) _LogItAlways(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
619 /** @todo invent a flag or something for skipping the group check so we can pass iGroup. LogItAlways. */
621 # define LogIt(a_fFlags, a_iGroup, fmtargs) \
624 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
625 if (RT_LIKELY(!LogIt_pLogger)) \
629 LogIt_pLogger->pfnLogger fmtargs; \
632 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) \
635 register PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(0, UINT16_MAX)); \
637 LogIt_pLogger->pfnLogger fmtargs; \
641 # define LogIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
642 # define LogItAlways(a_fFlags, a_iGroup, fmtargs) do { } while (0)
643 # if defined(LOG_USE_C99)
644 # define _LogRemoveParentheseis(...) __VA_ARGS__
645 # define _LogIt(a_fFlags, a_iGroup, ...) do { } while (0)
646 # define _LogItAlways(a_fFlags, a_iGroup, ...) do { } while (0)
651 /** @name Basic logging macros
654 * Level 1 logging that works regardless of the group settings.
656 #define LogAlways(a) LogItAlways(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
661 #define Log(a) LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
666 #define Log2(a) LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
671 #define Log3(a) LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
676 #define Log4(a) LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
681 #define Log5(a) LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
686 #define Log6(a) LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
691 #define Log7(a) LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
696 #define Log8(a) LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
701 #define Log9(a) LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
706 #define Log10(a) LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
711 #define Log11(a) LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
716 #define Log12(a) LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
719 * Logging of execution flow.
721 #define LogFlow(a) LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
724 * Logging of warnings.
726 #define LogWarn(a) LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
730 /** @name Logging macros prefixing the current function name.
733 * Level 1 logging inside C/C++ functions.
735 * Prepends the given log message with the function name followed by a
736 * semicolon and space.
738 * @param a Log message in format <tt>("string\n" [, args])</tt>.
741 # define LogFunc(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
743 # define LogFunc(a) do { Log((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
747 * Level 2 logging inside C/C++ functions.
749 * Prepends the given log message with the function name followed by a
750 * semicolon and space.
752 * @param a Log message in format <tt>("string\n" [, args])</tt>.
755 # define Log2Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
757 # define Log2Func(a) do { Log2((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
761 * Level 3 logging inside C/C++ functions.
763 * Prepends the given log message with the function name followed by a
764 * semicolon and space.
766 * @param a Log message in format <tt>("string\n" [, args])</tt>.
769 # define Log3Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
771 # define Log3Func(a) do { Log3((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
775 * Level 4 logging inside C/C++ functions.
777 * Prepends the given log message with the function name followed by a
778 * semicolon and space.
780 * @param a Log message in format <tt>("string\n" [, args])</tt>.
783 # define Log4Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
785 # define Log4Func(a) do { Log4((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
789 * Level 5 logging inside C/C++ functions.
791 * Prepends the given log message with the function name followed by a
792 * semicolon and space.
794 * @param a Log message in format <tt>("string\n" [, args])</tt>.
797 # define Log5Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
799 # define Log5Func(a) do { Log5((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
803 * Level 6 logging inside C/C++ functions.
805 * Prepends the given log message with the function name followed by a
806 * semicolon and space.
808 * @param a Log message in format <tt>("string\n" [, args])</tt>.
811 # define Log6Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
813 # define Log6Func(a) do { Log6((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
817 * Level 7 logging inside C/C++ functions.
819 * Prepends the given log message with the function name followed by a
820 * semicolon and space.
822 * @param a Log message in format <tt>("string\n" [, args])</tt>.
825 # define Log7Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
827 # define Log7Func(a) do { Log7((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
831 * Level 8 logging inside C/C++ functions.
833 * Prepends the given log message with the function name followed by a
834 * semicolon and space.
836 * @param a Log message in format <tt>("string\n" [, args])</tt>.
839 # define Log8Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
841 # define Log8Func(a) do { Log8((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
845 * Level 9 logging inside C/C++ functions.
847 * Prepends the given log message with the function name followed by a
848 * semicolon and space.
850 * @param a Log message in format <tt>("string\n" [, args])</tt>.
853 # define Log9Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
855 # define Log9Func(a) do { Log9((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
859 * Level 10 logging inside C/C++ functions.
861 * Prepends the given log message with the function name followed by a
862 * semicolon and space.
864 * @param a Log message in format <tt>("string\n" [, args])</tt>.
867 # define Log10Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
869 # define Log10Func(a) do { Log10((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
873 * Level 11 logging inside C/C++ functions.
875 * Prepends the given log message with the function name followed by a
876 * semicolon and space.
878 * @param a Log message in format <tt>("string\n" [, args])</tt>.
881 # define Log11Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
883 # define Log11Func(a) do { Log11((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
887 * Level 12 logging inside C/C++ functions.
889 * Prepends the given log message with the function name followed by a
890 * semicolon and space.
892 * @param a Log message in format <tt>("string\n" [, args])</tt>.
895 # define Log12Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
897 # define Log12Func(a) do { Log12((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
901 * Macro to log the execution flow inside C/C++ functions.
903 * Prepends the given log message with the function name followed by
904 * a semicolon and space.
906 * @param a Log message in format <tt>("string\n" [, args])</tt>.
909 # define LogFlowFunc(a) \
910 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
912 # define LogFlowFunc(a) \
913 do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
917 * Macro to log a warning inside C/C++ functions.
919 * Prepends the given log message with the function name followed by
920 * a semicolon and space.
922 * @param a Log message in format <tt>("string\n" [, args])</tt>.
925 # define LogWarnFunc(a) \
926 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
928 # define LogWarnFunc(a) \
929 do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
934 /** @name Logging macros prefixing the this pointer value and method name.
938 * Level 1 logging inside a C++ non-static method, with object pointer and
939 * method name prefixed to the given message.
940 * @param a Log message in format <tt>("string\n" [, args])</tt>.
943 # define LogThisFunc(a) \
944 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
946 # define LogThisFunc(a) do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
949 /** @def Log2ThisFunc
950 * Level 2 logging inside a C++ non-static method, with object pointer and
951 * method name prefixed to the given message.
952 * @param a Log message in format <tt>("string\n" [, args])</tt>.
955 # define Log2ThisFunc(a) \
956 _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
958 # define Log2ThisFunc(a) do { Log2(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log2(a); } while (0)
961 /** @def Log3ThisFunc
962 * Level 3 logging inside a C++ non-static method, with object pointer and
963 * method name prefixed to the given message.
964 * @param a Log message in format <tt>("string\n" [, args])</tt>.
967 # define Log3ThisFunc(a) \
968 _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
970 # define Log3ThisFunc(a) do { Log3(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log3(a); } while (0)
973 /** @def Log4ThisFunc
974 * Level 4 logging inside a C++ non-static method, with object pointer and
975 * method name prefixed to the given message.
976 * @param a Log message in format <tt>("string\n" [, args])</tt>.
979 # define Log4ThisFunc(a) \
980 _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
982 # define Log4ThisFunc(a) do { Log4(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log4(a); } while (0)
985 /** @def Log5ThisFunc
986 * Level 5 logging inside a C++ non-static method, with object pointer and
987 * method name prefixed to the given message.
988 * @param a Log message in format <tt>("string\n" [, args])</tt>.
991 # define Log5ThisFunc(a) \
992 _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
994 # define Log5ThisFunc(a) do { Log5(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log5(a); } while (0)
997 /** @def Log6ThisFunc
998 * Level 6 logging inside a C++ non-static method, with object pointer and
999 * method name prefixed to the given message.
1000 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1003 # define Log6ThisFunc(a) \
1004 _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1006 # define Log6ThisFunc(a) do { Log6(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log6(a); } while (0)
1009 /** @def Log7ThisFunc
1010 * Level 7 logging inside a C++ non-static method, with object pointer and
1011 * method name prefixed to the given message.
1012 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1015 # define Log7ThisFunc(a) \
1016 _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1018 # define Log7ThisFunc(a) do { Log7(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log7(a); } while (0)
1021 /** @def Log8ThisFunc
1022 * Level 8 logging inside a C++ non-static method, with object pointer and
1023 * method name prefixed to the given message.
1024 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1027 # define Log8ThisFunc(a) \
1028 _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1030 # define Log8ThisFunc(a) do { Log8(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log8(a); } while (0)
1033 /** @def Log9ThisFunc
1034 * Level 9 logging inside a C++ non-static method, with object pointer and
1035 * method name prefixed to the given message.
1036 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1039 # define Log9ThisFunc(a) \
1040 _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1042 # define Log9ThisFunc(a) do { Log9(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log9(a); } while (0)
1045 /** @def Log10ThisFunc
1046 * Level 10 logging inside a C++ non-static method, with object pointer and
1047 * method name prefixed to the given message.
1048 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1051 # define Log10ThisFunc(a) \
1052 _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1054 # define Log10ThisFunc(a) do { Log10(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log10(a); } while (0)
1057 /** @def Log11ThisFunc
1058 * Level 11 logging inside a C++ non-static method, with object pointer and
1059 * method name prefixed to the given message.
1060 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1063 # define Log11ThisFunc(a) \
1064 _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1066 # define Log11ThisFunc(a) do { Log11(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log11(a); } while (0)
1069 /** @def Log12ThisFunc
1070 * Level 12 logging inside a C++ non-static method, with object pointer and
1071 * method name prefixed to the given message.
1072 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1075 # define Log12ThisFunc(a) \
1076 _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1078 # define Log12ThisFunc(a) do { Log12(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log12(a); } while (0)
1081 /** @def LogFlowThisFunc
1082 * Flow level logging inside a C++ non-static method, with object pointer and
1083 * method name prefixed to the given message.
1084 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1087 # define LogFlowThisFunc(a) \
1088 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1090 # define LogFlowThisFunc(a) do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
1093 /** @def LogWarnThisFunc
1094 * Warning level logging inside a C++ non-static method, with object pointer and
1095 * method name prefixed to the given message.
1096 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1099 # define LogWarnThisFunc(a) \
1100 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1102 # define LogWarnThisFunc(a) do { LogWarn(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogWarn(a); } while (0)
1107 /** @name Misc Logging Macros
1110 /** @def Log1Warning
1111 * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
1113 * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
1115 #if defined(LOG_USE_C99)
1116 # define Log1Warning(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a )
1118 # define Log1Warning(a) do { Log(("WARNING! ")); Log(a); } while (0)
1121 /** @def Log1WarningFunc
1122 * The same as LogWarning(), but prepents the log message with the function name.
1124 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1127 # define Log1WarningFunc(a) \
1128 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1130 # define Log1WarningFunc(a) \
1131 do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0)
1134 /** @def Log1WarningThisFunc
1135 * The same as LogWarningFunc() but for class functions (methods): the resulting
1136 * log line is additionally prepended with a hex value of |this| pointer.
1138 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1141 # define Log1WarningThisFunc(a) \
1142 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1144 # define Log1WarningThisFunc(a) \
1145 do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(a); } while (0)
1149 /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1150 #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
1152 /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */
1153 #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
1155 /** Shortcut to |LogFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1156 #define LogFlowFuncLeaveRC(rc) LogFlowFunc(("LEAVE: %Rrc\n", (rc)))
1158 /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1159 #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
1161 /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1162 #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
1165 /** @def LogObjRefCnt
1166 * Helper macro to print the current reference count of the given COM object
1169 * @param pObj Pointer to the object in question (must be a pointer to an
1170 * IUnknown subclass or simply define COM-style AddRef() and
1171 * Release() methods)
1173 #define LogObjRefCnt(pObj) \
1175 if (LogIsFlowEnabled()) \
1177 int cRefsForLog = (pObj)->AddRef(); \
1178 LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), cRefsForLog - 1)); \
1179 (pObj)->Release(); \
1186 /** @name Passing Function Call Position When Logging.
1188 * This is a little bit ugly as we have to omit the comma before the
1189 * position parameters so that we don't inccur any overhead in non-logging
1190 * builds (!defined(LOG_ENABLED).
1193 /** Source position for passing to a function call. */
1195 # define RTLOG_COMMA_SRC_POS , __FILE__, __LINE__, __PRETTY_FUNCTION__
1197 # define RTLOG_COMMA_SRC_POS RT_NOTHING
1199 /** Source position declaration. */
1201 # define RTLOG_COMMA_SRC_POS_DECL , const char *pszFile, unsigned iLine, const char *pszFunction
1203 # define RTLOG_COMMA_SRC_POS_DECL RT_NOTHING
1205 /** Source position arguments. */
1207 # define RTLOG_COMMA_SRC_POS_ARGS , pszFile, iLine, pszFunction
1209 # define RTLOG_COMMA_SRC_POS_ARGS RT_NOTHING
1211 /** Applies NOREF() to the source position arguments. */
1213 # define RTLOG_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
1215 # define RTLOG_SRC_POS_NOREF() do { } while (0)
1221 /** @name Release Logging
1225 #ifdef DOXYGEN_RUNNING
1226 # define RTLOG_REL_DISABLED
1227 # define RTLOG_REL_ENABLED
1230 /** @def RTLOG_REL_DISABLED
1231 * Use this compile time define to disable all release logging
1235 /** @def RTLOG_REL_ENABLED
1236 * Use this compile time define to override RTLOG_REL_DISABLE.
1240 * Determine whether release logging is enabled and forcefully normalize the indicators.
1242 #if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED)
1243 # undef RTLOG_REL_DISABLED
1244 # undef RTLOG_REL_ENABLED
1245 # define RTLOG_REL_ENABLED
1247 # undef RTLOG_REL_ENABLED
1248 # undef RTLOG_REL_DISABLED
1249 # define RTLOG_REL_DISABLED
1252 /** @name Macros for checking whether a release log level is enabled.
1254 /** @def LogRelIsItEnabled
1255 * Checks whether the specified release logging group is enabled or not.
1257 #define LogRelIsItEnabled(a_fFlags, a_iGroup) ( RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
1259 /** @def LogRelIsEnabled
1260 * Checks whether level 1 release logging is enabled.
1262 #define LogRelIsEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
1264 /** @def LogRelIs2Enabled
1265 * Checks whether level 2 release logging is enabled.
1267 #define LogRelIs2Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
1269 /** @def LogRelIs3Enabled
1270 * Checks whether level 3 release logging is enabled.
1272 #define LogRelIs3Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
1274 /** @def LogRelIs4Enabled
1275 * Checks whether level 4 release logging is enabled.
1277 #define LogRelIs4Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
1279 /** @def LogRelIs5Enabled
1280 * Checks whether level 5 release logging is enabled.
1282 #define LogRelIs5Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
1284 /** @def LogRelIs6Enabled
1285 * Checks whether level 6 release logging is enabled.
1287 #define LogRelIs6Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
1289 /** @def LogRelIs7Enabled
1290 * Checks whether level 7 release logging is enabled.
1292 #define LogRelIs7Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
1294 /** @def LogRelIs8Enabled
1295 * Checks whether level 8 release logging is enabled.
1297 #define LogRelIs8Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
1299 /** @def LogRelIs2Enabled
1300 * Checks whether level 9 release logging is enabled.
1302 #define LogRelIs9Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
1304 /** @def LogRelIs10Enabled
1305 * Checks whether level 10 release logging is enabled.
1307 #define LogRelIs10Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
1309 /** @def LogRelIs11Enabled
1310 * Checks whether level 10 release logging is enabled.
1312 #define LogRelIs11Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
1314 /** @def LogRelIs12Enabled
1315 * Checks whether level 12 release logging is enabled.
1317 #define LogRelIs12Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
1319 /** @def LogRelIsFlowEnabled
1320 * Checks whether execution flow release logging is enabled.
1322 #define LogRelIsFlowEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1324 /** @def LogRelIsWarnEnabled
1325 * Checks whether warning level release logging is enabled.
1327 #define LogRelIsWarnEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1332 * Write to specific logger if group enabled.
1334 /** @def LogRelItLikely
1335 * Write to specific logger if group enabled, assuming it likely it is enabled.
1337 /** @def LogRelMaxIt
1338 * Write to specific logger if group enabled and at less than a_cMax messages
1339 * have hit the log. Uses a static variable to count.
1341 #ifdef RTLOG_REL_ENABLED
1342 # if defined(LOG_USE_C99)
1343 # define _LogRelRemoveParentheseis(...) __VA_ARGS__
1344 # define _LogRelIt(a_fFlags, a_iGroup, ...) \
1347 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1348 if (RT_LIKELY(!LogRelIt_pLogger)) \
1351 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1352 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1354 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1355 _LogRelIt(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1356 # define _LogRelItLikely(a_fFlags, a_iGroup, ...) \
1359 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1360 if (LogRelIt_pLogger) \
1361 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1362 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1364 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1365 _LogRelItLikely(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1366 # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) \
1369 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1370 if (LogRelIt_pLogger) \
1372 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1373 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1375 s_LogRelMaxIt_cLogged++; \
1376 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1379 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1381 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1382 _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1384 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1387 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1388 if (LogRelIt_pLogger) \
1390 LogRelIt_pLogger->pfnLogger fmtargs; \
1392 LogIt(a_fFlags, a_iGroup, fmtargs); \
1394 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1397 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1398 if (RT_LIKELY(!LogRelIt_pLogger)) \
1402 LogRelIt_pLogger->pfnLogger fmtargs; \
1404 LogIt(a_fFlags, a_iGroup, fmtargs); \
1406 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1409 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1410 if (LogRelIt_pLogger) \
1412 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1413 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1415 s_LogRelMaxIt_cLogged++; \
1416 LogRelIt_pLogger->pfnLogger fmtargs; \
1419 LogIt(a_fFlags, a_iGroup, fmtargs); \
1422 #else /* !RTLOG_REL_ENABLED */
1423 # define LogRelIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1424 # define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1425 # define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) do { } while (0)
1426 # if defined(LOG_USE_C99)
1427 # define _LogRelRemoveParentheseis(...) __VA_ARGS__
1428 # define _LogRelIt(a_fFlags, a_iGroup, ...) do { } while (0)
1429 # define _LogRelItLikely(a_fFlags, a_iGroup, ...) do { } while (0)
1430 # define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) do { } while (0)
1432 #endif /* !RTLOG_REL_ENABLED */
1435 /** @name Basic release logging macros
1438 * Level 1 release logging.
1440 #define LogRel(a) LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1443 * Level 2 release logging.
1445 #define LogRel2(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1448 * Level 3 release logging.
1450 #define LogRel3(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1453 * Level 4 release logging.
1455 #define LogRel4(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1458 * Level 5 release logging.
1460 #define LogRel5(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1463 * Level 6 release logging.
1465 #define LogRel6(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1468 * Level 7 release logging.
1470 #define LogRel7(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1473 * Level 8 release logging.
1475 #define LogRel8(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1478 * Level 9 release logging.
1480 #define LogRel9(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1483 * Level 10 release logging.
1485 #define LogRel10(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1488 * Level 11 release logging.
1490 #define LogRel11(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1493 * Level 12 release logging.
1495 #define LogRel12(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1498 * Logging of execution flow.
1500 #define LogRelFlow(a) LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1503 * Warning level release logging.
1505 #define LogRelWarn(a) LogRelIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
1510 /** @name Basic release logging macros with local max
1513 * Level 1 release logging with a max number of log entries.
1515 #define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1518 * Level 2 release logging with a max number of log entries.
1520 #define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1523 * Level 3 release logging with a max number of log entries.
1525 #define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1528 * Level 4 release logging with a max number of log entries.
1530 #define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1533 * Level 5 release logging with a max number of log entries.
1535 #define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1538 * Level 6 release logging with a max number of log entries.
1540 #define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1543 * Level 7 release logging with a max number of log entries.
1545 #define LogRelMax7(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1548 * Level 8 release logging with a max number of log entries.
1550 #define LogRelMax8(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1553 * Level 9 release logging with a max number of log entries.
1555 #define LogRelMax9(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1557 /** @def LogRelMax10
1558 * Level 10 release logging with a max number of log entries.
1560 #define LogRelMax10(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1562 /** @def LogRelMax11
1563 * Level 11 release logging with a max number of log entries.
1565 #define LogRelMax11(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1567 /** @def LogRelMax12
1568 * Level 12 release logging with a max number of log entries.
1570 #define LogRelMax12(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1572 /** @def LogRelMaxFlow
1573 * Logging of execution flow with a max number of log entries.
1575 #define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1579 /** @name Release logging macros prefixing the current function name.
1583 * Release logging. Prepends the given log message with the function name
1584 * followed by a semicolon and space.
1587 # define LogRelFunc(a) \
1588 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1590 # define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1593 /** @def LogRelFlowFunc
1594 * Release logging. Macro to log the execution flow inside C/C++ functions.
1596 * Prepends the given log message with the function name followed by
1597 * a semicolon and space.
1599 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1602 # define LogRelFlowFunc(a) _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1604 # define LogRelFlowFunc(a) do { LogRelFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1607 /** @def LogRelMaxFunc
1608 * Release logging. Prepends the given log message with the function name
1609 * followed by a semicolon and space.
1612 # define LogRelMaxFunc(a_cMax, a) \
1613 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1615 # define LogRelMaxFunc(a_cMax, a) \
1616 do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1619 /** @def LogRelMaxFlowFunc
1620 * Release logging. Macro to log the execution flow inside C/C++ functions.
1622 * Prepends the given log message with the function name followed by
1623 * a semicolon and space.
1625 * @param a_cMax Max number of times this should hit the log.
1626 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1629 # define LogRelMaxFlowFunc(a_cMax, a) \
1630 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1632 # define LogRelMaxFlowFunc(a_cMax, a) \
1633 do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0)
1639 /** @name Release Logging macros prefixing the this pointer value and method name.
1642 /** @def LogRelThisFunc
1643 * The same as LogRelFunc but for class functions (methods): the resulting log
1644 * line is additionally prepended with a hex value of |this| pointer.
1647 # define LogRelThisFunc(a) \
1648 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1650 # define LogRelThisFunc(a) \
1651 do { LogRel(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1654 /** @def LogRelMaxThisFunc
1655 * The same as LogRelFunc but for class functions (methods): the resulting log
1656 * line is additionally prepended with a hex value of |this| pointer.
1657 * @param a_cMax Max number of times this should hit the log.
1658 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1661 # define LogRelMaxThisFunc(a_cMax, a) \
1662 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1664 # define LogRelMaxThisFunc(a_cMax, a) \
1665 do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1668 /** @def LogRelFlowThisFunc
1669 * The same as LogRelFlowFunc but for class functions (methods): the resulting
1670 * log line is additionally prepended with a hex value of |this| pointer.
1673 # define LogRelFlowThisFunc(a) \
1674 _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1676 # define LogRelFlowThisFunc(a) do { LogRelFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1680 /** Shortcut to |LogRelFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1681 #define LogRelFlowFuncEnter() LogRelFlowFunc(("ENTER\n"))
1683 /** Shortcut to |LogRelFlowFunc ("LEAVE\n")|, marks the end of the function. */
1684 #define LogRelFlowFuncLeave() LogRelFlowFunc(("LEAVE\n"))
1686 /** Shortcut to |LogRelFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1687 #define LogRelFlowFuncLeaveRC(rc) LogRelFlowFunc(("LEAVE: %Rrc\n", (rc)))
1689 /** Shortcut to |LogRelFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1690 #define LogRelFlowThisFuncEnter() LogRelFlowThisFunc(("ENTER\n"))
1692 /** Shortcut to |LogRelFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1693 #define LogRelFlowThisFuncLeave() LogRelFlowThisFunc(("LEAVE\n"))
1700 * Sets the default release logger instance.
1702 * @returns The old default instance.
1703 * @param pLogger The new default release logger instance.
1705 RTDECL(PRTLOGGER
) RTLogRelSetDefaultInstance(PRTLOGGER pLogger
);
1709 * Gets the default release logger instance.
1711 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1713 RTDECL(PRTLOGGER
) RTLogRelGetDefaultInstance(void);
1716 * Gets the default release logger instance.
1718 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1719 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1722 RTDECL(PRTLOGGER
) RTLogRelGetDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1725 * Write to a logger instance, defaulting to the release one.
1727 * This function will check whether the instance, group and flags makes up a
1728 * logging kind which is currently enabled before writing anything to the log.
1730 * @param pLogger Pointer to logger instance.
1731 * @param fFlags The logging flags.
1732 * @param iGroup The group.
1733 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1734 * only for internal usage!
1735 * @param pszFormat Format string.
1736 * @param ... Format arguments.
1737 * @remark This is a worker function for LogRelIt.
1739 RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
1740 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
1743 * Write to a logger instance, defaulting to the release one.
1745 * This function will check whether the instance, group and flags makes up a
1746 * logging kind which is currently enabled before writing anything to the log.
1748 * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
1749 * @param fFlags The logging flags.
1750 * @param iGroup The group.
1751 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1752 * only for internal usage!
1753 * @param pszFormat Format string.
1754 * @param args Format arguments.
1756 RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
1757 const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(4, 0);
1760 * printf like function for writing to the default release log.
1762 * @param pszFormat Printf like format string.
1763 * @param ... Optional arguments as specified in pszFormat.
1765 * @remark The API doesn't support formatting of floating point numbers at the moment.
1767 RTDECL(void) RTLogRelPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
1770 * vprintf like function for writing to the default release log.
1772 * @param pszFormat Printf like format string.
1773 * @param args Optional arguments as specified in pszFormat.
1775 * @remark The API doesn't support formatting of floating point numbers at the moment.
1777 RTDECL(void) RTLogRelPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);
1780 * Changes the buffering setting of the default release logger.
1782 * This can be used for optimizing longish logging sequences.
1784 * @returns The old state.
1785 * @param fBuffered The new state.
1787 RTDECL(bool) RTLogRelSetBuffering(bool fBuffered
);
1793 /** @name COM port logging
1797 #ifdef DOXYGEN_RUNNING
1803 * Redirects the normal logging macros to the serial versions.
1807 * Disables all LogCom* macros.
1811 * Generic logging to serial port.
1813 #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
1814 # define LogCom(a) RTLogComPrintf a
1816 # define LogCom(a) do { } while (0)
1820 * Logging to serial port of execution flow.
1822 #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
1823 # define LogComFlow(a) RTLogComPrintf a
1825 # define LogComFlow(a) do { } while (0)
1830 # define Log(a) LogCom(a)
1832 # define LogFlow(a) LogComFlow(a)
1838 /** @name Backdoor Logging
1842 #ifdef DOXYGEN_RUNNING
1843 # define LOG_TO_BACKDOOR
1844 # define LOG_NO_BACKDOOR
1847 /** @def LOG_TO_BACKDOOR
1848 * Redirects the normal logging macros to the backdoor versions.
1851 /** @def LOG_NO_BACKDOOR
1852 * Disables all LogBackdoor* macros.
1855 /** @def LogBackdoor
1856 * Generic logging to the VBox backdoor via port I/O.
1858 #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1859 # define LogBackdoor(a) RTLogBackdoorPrintf a
1861 # define LogBackdoor(a) do { } while (0)
1864 /** @def LogBackdoorFlow
1865 * Logging of execution flow messages to the backdoor I/O port.
1867 #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1868 # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
1870 # define LogBackdoorFlow(a) do { } while (0)
1873 /** @def LogRelBackdoor
1874 * Release logging to the VBox backdoor via port I/O.
1876 #if !defined(LOG_NO_BACKDOOR)
1877 # define LogRelBackdoor(a) RTLogBackdoorPrintf a
1879 # define LogRelBackdoor(a) do { } while (0)
1882 #ifdef LOG_TO_BACKDOOR
1884 # define Log(a) LogBackdoor(a)
1886 # define LogFlow(a) LogBackdoorFlow(a)
1888 # define LogRel(a) LogRelBackdoor(a)
1889 # if defined(LOG_USE_C99)
1891 # define _LogIt(a_fFlags, a_iGroup, ...) LogBackdoor((__VA_ARGS__))
1900 * Gets the default logger instance, creating it if necessary.
1902 * @returns Pointer to default logger instance if availble, otherwise NULL.
1904 RTDECL(PRTLOGGER
) RTLogDefaultInstance(void);
1907 * Gets the logger instance if enabled, creating it if necessary.
1909 * @returns Pointer to default logger instance, if group has the specified
1910 * flags enabled. Otherwise NULL is returned.
1911 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1914 RTDECL(PRTLOGGER
) RTLogDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1917 * Gets the default logger instance.
1919 * @returns Pointer to default logger instance if availble, otherwise NULL.
1921 RTDECL(PRTLOGGER
) RTLogGetDefaultInstance(void);
1924 * Gets the default logger instance if enabled.
1926 * @returns Pointer to default logger instance, if group has the specified
1927 * flags enabled. Otherwise NULL is returned.
1928 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1931 RTDECL(PRTLOGGER
) RTLogGetDefaultInstanceEx(uint32_t fFlagsAndGroup
);
1935 * Sets the default logger instance.
1937 * @returns The old default instance.
1938 * @param pLogger The new default logger instance.
1940 RTDECL(PRTLOGGER
) RTLogSetDefaultInstance(PRTLOGGER pLogger
);
1945 * Changes the default logger instance for the current thread.
1947 * @returns IPRT status code.
1948 * @param pLogger The logger instance. Pass NULL for deregistration.
1949 * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
1950 * all instances with this key will be deregistered. So in
1951 * order to only deregister the instance associated with the
1952 * current thread use 0.
1954 RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger
, uintptr_t uKey
);
1955 #endif /* IN_RING0 */
1960 * Creates the default logger instance for a iprt users.
1962 * Any user of the logging features will need to implement
1963 * this or use the generic dummy.
1965 * @returns Pointer to the logger instance.
1967 RTDECL(PRTLOGGER
) RTLogDefaultInit(void);
1970 * Create a logger instance.
1972 * @returns iprt status code.
1974 * @param ppLogger Where to store the logger instance.
1975 * @param fFlags Logger instance flags, a combination of the
1976 * RTLOGFLAGS_* values.
1977 * @param pszGroupSettings The initial group settings.
1978 * @param pszEnvVarBase Base name for the environment variables for
1980 * @param cGroups Number of groups in the array.
1981 * @param papszGroups Pointer to array of groups. This must stick
1982 * around for the life of the logger instance.
1983 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
1984 * if pszFilenameFmt specified.
1985 * @param pszFilenameFmt Log filename format string. Standard
1987 * @param ... Format arguments.
1989 RTDECL(int) RTLogCreate(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
1990 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
1991 uint32_t fDestFlags
, const char *pszFilenameFmt
, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
1994 * Create a logger instance.
1996 * @returns iprt status code.
1998 * @param ppLogger Where to store the logger instance.
1999 * @param fFlags Logger instance flags, a combination of the
2000 * RTLOGFLAGS_* values.
2001 * @param pszGroupSettings The initial group settings.
2002 * @param pszEnvVarBase Base name for the environment variables for
2004 * @param cGroups Number of groups in the array.
2005 * @param papszGroups Pointer to array of groups. This must stick
2006 * around for the life of the logger instance.
2007 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2008 * if pszFilenameFmt specified.
2009 * @param pfnPhase Callback function for starting logging and for
2010 * ending or starting a new file for log history
2011 * rotation. NULL is OK.
2012 * @param cHistory Number of old log files to keep when performing
2013 * log history rotation. 0 means no history.
2014 * @param cbHistoryFileMax Maximum size of log file when performing
2015 * history rotation. 0 means no size limit.
2016 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2017 * performing history rotation, in seconds.
2018 * 0 means time limit.
2019 * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
2020 * @param cchErrorMsg The size of the error message buffer.
2021 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
2022 * @param ... Format arguments.
2024 RTDECL(int) RTLogCreateEx(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
2025 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
2026 uint32_t fDestFlags
, PFNRTLOGPHASE pfnPhase
, uint32_t cHistory
,
2027 uint64_t cbHistoryFileMax
, uint32_t cSecsHistoryTimeSlot
, char *pszErrorMsg
, size_t cchErrorMsg
,
2028 const char *pszFilenameFmt
, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(14, 15);
2031 * Create a logger instance.
2033 * @returns iprt status code.
2035 * @param ppLogger Where to store the logger instance.
2036 * @param fFlags Logger instance flags, a combination of the
2037 * RTLOGFLAGS_* values.
2038 * @param pszGroupSettings The initial group settings.
2039 * @param pszEnvVarBase Base name for the environment variables for
2041 * @param cGroups Number of groups in the array.
2042 * @param papszGroups Pointer to array of groups. This must stick
2043 * around for the life of the logger instance.
2044 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2045 * if pszFilenameFmt specified.
2046 * @param pfnPhase Callback function for starting logging and for
2047 * ending or starting a new file for log history
2049 * @param cHistory Number of old log files to keep when performing
2050 * log history rotation. 0 means no history.
2051 * @param cbHistoryFileMax Maximum size of log file when performing
2052 * history rotation. 0 means no size limit.
2053 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2054 * performing history rotation, in seconds.
2055 * 0 means no time limit.
2056 * @param pszErrorMsg A buffer which is filled with an error message
2057 * if something fails. May be NULL.
2058 * @param cchErrorMsg The size of the error message buffer.
2059 * @param pszFilenameFmt Log filename format string. Standard
2061 * @param args Format arguments.
2063 RTDECL(int) RTLogCreateExV(PRTLOGGER
*ppLogger
, uint32_t fFlags
, const char *pszGroupSettings
,
2064 const char *pszEnvVarBase
, unsigned cGroups
, const char * const * papszGroups
,
2065 uint32_t fDestFlags
, PFNRTLOGPHASE pfnPhase
, uint32_t cHistory
,
2066 uint64_t cbHistoryFileMax
, uint32_t cSecsHistoryTimeSlot
, char *pszErrorMsg
, size_t cchErrorMsg
,
2067 const char *pszFilenameFmt
, va_list args
) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(14, 0);
2070 * Create a logger instance for singled threaded ring-0 usage.
2072 * @returns iprt status code.
2074 * @param pLogger Where to create the logger instance.
2075 * @param cbLogger The amount of memory available for the logger instance.
2076 * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
2077 * @param pfnLoggerR0Ptr Pointer to logger wrapper function.
2078 * @param pfnFlushR0Ptr Pointer to flush function.
2079 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
2080 * @param fDestFlags The destination flags.
2082 RTDECL(int) RTLogCreateForR0(PRTLOGGER pLogger
, size_t cbLogger
,
2083 RTR0PTR pLoggerR0Ptr
, RTR0PTR pfnLoggerR0Ptr
, RTR0PTR pfnFlushR0Ptr
,
2084 uint32_t fFlags
, uint32_t fDestFlags
);
2087 * Calculates the minimum size of a ring-0 logger instance.
2089 * @returns The minimum size.
2090 * @param cGroups The number of groups.
2091 * @param fFlags Relevant flags.
2093 RTDECL(size_t) RTLogCalcSizeForR0(uint32_t cGroups
, uint32_t fFlags
);
2096 * Destroys a logger instance.
2098 * The instance is flushed and all output destinations closed (where applicable).
2100 * @returns iprt status code.
2101 * @param pLogger The logger instance which close destroyed. NULL is fine.
2103 RTDECL(int) RTLogDestroy(PRTLOGGER pLogger
);
2106 * Create a logger instance clone for RC usage.
2108 * @returns iprt status code.
2110 * @param pLogger The logger instance to be cloned.
2111 * @param pLoggerRC Where to create the RC logger instance.
2112 * @param cbLoggerRC Amount of memory allocated to for the RC logger
2114 * @param pfnLoggerRCPtr Pointer to logger wrapper function for this
2115 * instance (RC Ptr).
2116 * @param pfnFlushRCPtr Pointer to flush function (RC Ptr).
2117 * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
2119 RTDECL(int) RTLogCloneRC(PRTLOGGER pLogger
, PRTLOGGERRC pLoggerRC
, size_t cbLoggerRC
,
2120 RTRCPTR pfnLoggerRCPtr
, RTRCPTR pfnFlushRCPtr
, uint32_t fFlags
);
2123 * Flushes a RC logger instance to a R3 logger.
2125 * @returns iprt status code.
2126 * @param pLogger The R3 logger instance to flush pLoggerRC to. If NULL
2127 * the default logger is used.
2128 * @param pLoggerRC The RC logger instance to flush.
2130 RTDECL(void) RTLogFlushRC(PRTLOGGER pLogger
, PRTLOGGERRC pLoggerRC
);
2133 * Flushes the buffer in one logger instance onto another logger.
2135 * @returns iprt status code.
2137 * @param pSrcLogger The logger instance to flush.
2138 * @param pDstLogger The logger instance to flush onto.
2139 * If NULL the default logger will be used.
2141 RTDECL(void) RTLogFlushToLogger(PRTLOGGER pSrcLogger
, PRTLOGGER pDstLogger
);
2144 * Flushes a R0 logger instance to a R3 logger.
2146 * @returns iprt status code.
2147 * @param pLogger The R3 logger instance to flush pLoggerR0 to. If NULL
2148 * the default logger is used.
2149 * @param pLoggerR0 The R0 logger instance to flush.
2151 RTDECL(void) RTLogFlushR0(PRTLOGGER pLogger
, PRTLOGGER pLoggerR0
);
2154 * Sets the custom prefix callback.
2156 * @returns IPRT status code.
2157 * @param pLogger The logger instance.
2158 * @param pfnCallback The callback.
2159 * @param pvUser The user argument for the callback.
2161 RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger
, PFNRTLOGPREFIX pfnCallback
, void *pvUser
);
2164 * Same as RTLogSetCustomPrefixCallback for loggers created by
2167 * @returns IPRT status code.
2168 * @param pLogger The logger instance.
2169 * @param pLoggerR0Ptr The ring-0 address corresponding to @a pLogger.
2170 * @param pfnCallbackR0Ptr The callback.
2171 * @param pvUserR0Ptr The user argument for the callback.
2173 RTDECL(int) RTLogSetCustomPrefixCallbackForR0(PRTLOGGER pLogger
, RTR0PTR pLoggerR0Ptr
,
2174 RTR0PTR pfnCallbackR0Ptr
, RTR0PTR pvUserR0Ptr
);
2177 * Copies the group settings and flags from logger instance to another.
2179 * @returns IPRT status code.
2180 * @param pDstLogger The destination logger instance.
2181 * @param pDstLoggerR0Ptr The ring-0 address corresponding to @a pDstLogger.
2182 * @param pSrcLogger The source logger instance. If NULL the default one is used.
2183 * @param fFlagsOr OR mask for the flags.
2184 * @param fFlagsAnd AND mask for the flags.
2186 RTDECL(int) RTLogCopyGroupsAndFlagsForR0(PRTLOGGER pDstLogger
, RTR0PTR pDstLoggerR0Ptr
,
2187 PCRTLOGGER pSrcLogger
, uint32_t fFlagsOr
, uint32_t fFlagsAnd
);
2190 * Get the current log group settings as a string.
2192 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2193 * @param pLogger Logger instance (NULL for default logger).
2194 * @param pszBuf The output buffer.
2195 * @param cchBuf The size of the output buffer. Must be greater
2198 RTDECL(int) RTLogGetGroupSettings(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2201 * Updates the group settings for the logger instance using the specified
2202 * specification string.
2204 * @returns iprt status code.
2205 * Failures can safely be ignored.
2206 * @param pLogger Logger instance (NULL for default logger).
2207 * @param pszValue Value to parse.
2209 RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger
, const char *pszValue
);
2213 * Updates the flags for the logger instance using the specified
2214 * specification string.
2216 * @returns iprt status code.
2217 * Failures can safely be ignored.
2218 * @param pLogger Logger instance (NULL for default logger).
2219 * @param pszValue Value to parse.
2221 RTDECL(int) RTLogFlags(PRTLOGGER pLogger
, const char *pszValue
);
2224 * Changes the buffering setting of the specified logger.
2226 * This can be used for optimizing longish logging sequences.
2228 * @returns The old state.
2229 * @param pLogger The logger instance (NULL is an alias for the
2231 * @param fBuffered The new state.
2233 RTDECL(bool) RTLogSetBuffering(PRTLOGGER pLogger
, bool fBuffered
);
2236 * Sets the max number of entries per group.
2238 * @returns Old restriction.
2240 * @param pLogger The logger instance (NULL is an alias for the
2242 * @param cMaxEntriesPerGroup The max number of entries per group.
2244 * @remarks Lowering the limit of an active logger may quietly mute groups.
2245 * Raising it may reactive already muted groups.
2247 RTDECL(uint32_t) RTLogSetGroupLimit(PRTLOGGER pLogger
, uint32_t cMaxEntriesPerGroup
);
2251 * Get the current log flags as a string.
2253 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2254 * @param pLogger Logger instance (NULL for default logger).
2255 * @param pszBuf The output buffer.
2256 * @param cchBuf The size of the output buffer. Must be greater
2259 RTDECL(int) RTLogGetFlags(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2262 * Updates the logger destination using the specified string.
2264 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2265 * @param pLogger Logger instance (NULL for default logger).
2266 * @param pszValue The value to parse.
2268 RTDECL(int) RTLogDestinations(PRTLOGGER pLogger
, char const *pszValue
);
2271 * Get the current log destinations as a string.
2273 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2274 * @param pLogger Logger instance (NULL for default logger).
2275 * @param pszBuf The output buffer.
2276 * @param cchBuf The size of the output buffer. Must be greater
2279 RTDECL(int) RTLogGetDestinations(PRTLOGGER pLogger
, char *pszBuf
, size_t cchBuf
);
2283 * Flushes the specified logger.
2285 * @param pLogger The logger instance to flush.
2286 * If NULL the default instance is used. The default instance
2287 * will not be initialized by this call.
2289 RTDECL(void) RTLogFlush(PRTLOGGER pLogger
);
2292 * Write to a logger instance.
2294 * @param pLogger Pointer to logger instance.
2295 * @param pvCallerRet Ignored.
2296 * @param pszFormat Format string.
2297 * @param ... Format arguments.
2299 RTDECL(void) RTLogLogger(PRTLOGGER pLogger
, void *pvCallerRet
, const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(3, 4);
2302 * Write to a logger instance.
2304 * @param pLogger Pointer to logger instance.
2305 * @param pszFormat Format string.
2306 * @param args Format arguments.
2308 RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger
, const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(3, 0);
2311 * Write to a logger instance.
2313 * This function will check whether the instance, group and flags makes up a
2314 * logging kind which is currently enabled before writing anything to the log.
2316 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2317 * @param fFlags The logging flags.
2318 * @param iGroup The group.
2319 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2320 * only for internal usage!
2321 * @param pszFormat Format string.
2322 * @param ... Format arguments.
2323 * @remark This is a worker function of LogIt.
2325 RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
2326 const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(4, 5);
2329 * Write to a logger instance.
2331 * This function will check whether the instance, group and flags makes up a
2332 * logging kind which is currently enabled before writing anything to the log.
2334 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2335 * @param fFlags The logging flags.
2336 * @param iGroup The group.
2337 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2338 * only for internal usage!
2339 * @param pszFormat Format string.
2340 * @param args Format arguments.
2342 RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger
, unsigned fFlags
, unsigned iGroup
,
2343 const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(4, 0);
2346 * printf like function for writing to the default log.
2348 * @param pszFormat Printf like format string.
2349 * @param ... Optional arguments as specified in pszFormat.
2351 * @remark The API doesn't support formatting of floating point numbers at the moment.
2353 RTDECL(void) RTLogPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2356 * vprintf like function for writing to the default log.
2358 * @param pszFormat Printf like format string.
2359 * @param va Optional arguments as specified in pszFormat.
2361 * @remark The API doesn't support formatting of floating point numbers at the moment.
2363 RTDECL(void) RTLogPrintfV(const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(1, 0);
2366 * Dumper vprintf-like function outputting to a logger.
2368 * @param pvUser Pointer to the logger instance to use, NULL for
2370 * @param pszFormat Format string.
2371 * @param va Format arguments.
2373 RTDECL(void) RTLogDumpPrintfV(void *pvUser
, const char *pszFormat
, va_list va
) RT_IPRT_FORMAT_ATTR(2, 0);
2376 #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
2377 #define DECLARED_FNRTSTROUTPUT
2381 * @returns number of bytes written.
2382 * @param pvArg User argument.
2383 * @param pachChars Pointer to an array of utf-8 characters.
2384 * @param cbChars Number of bytes in the character array pointed to by pachChars.
2386 typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg
, const char *pachChars
, size_t cbChars
);
2387 /** Pointer to callback function. */
2388 typedef FNRTSTROUTPUT
*PFNRTSTROUTPUT
;
2392 * Partial vsprintf worker implementation.
2394 * @returns number of bytes formatted.
2395 * @param pfnOutput Output worker.
2396 * Called in two ways. Normally with a string an it's length.
2397 * For termination, it's called with NULL for string, 0 for length.
2398 * @param pvArg Argument to output worker.
2399 * @param pszFormat Format string.
2400 * @param args Argument list.
2402 RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput
, void *pvArg
, const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(3, 0);
2405 * Write log buffer to COM port.
2407 * @param pach Pointer to the buffer to write.
2408 * @param cb Number of bytes to write.
2410 RTDECL(void) RTLogWriteCom(const char *pach
, size_t cb
);
2413 * Prints a formatted string to the serial port used for logging.
2415 * @returns Number of bytes written.
2416 * @param pszFormat Format string.
2417 * @param ... Optional arguments specified in the format string.
2419 RTDECL(size_t) RTLogComPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2422 * Prints a formatted string to the serial port used for logging.
2424 * @returns Number of bytes written.
2425 * @param pszFormat Format string.
2426 * @param args Optional arguments specified in the format string.
2428 RTDECL(size_t) RTLogComPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);
2431 #if 0 /* not implemented yet */
2433 /** Indicates that the semaphores shall be used to notify the other
2434 * part about buffer changes. */
2435 #define LOGHOOKBUFFER_FLAGS_SEMAPHORED 1
2439 * Use to communicate between the logger and a log consumer.
2441 typedef struct RTLOGHOOKBUFFER
2443 /** Write pointer. */
2444 volatile void *pvWrite
;
2445 /** Read pointer. */
2446 volatile void *pvRead
;
2447 /** Buffer start. */
2449 /** Buffer end (exclusive). */
2451 /** Signaling semaphore used by the writer to wait on a full buffer.
2452 * Only used when indicated in flags. */
2454 /** Signaling semaphore used by the read to wait on an empty buffer.
2455 * Only used when indicated in flags. */
2457 /** Buffer flags. Current reserved and set to zero. */
2458 volatile unsigned fFlags
;
2460 /** Pointer to a log hook buffer. */
2461 typedef RTLOGHOOKBUFFER
*PRTLOGHOOKBUFFER
;
2465 * Register a logging hook.
2467 * This type of logging hooks are expecting different threads acting
2468 * producer and consumer. They share a circular buffer which have two
2469 * pointers one for each end. When the buffer is full there are two
2470 * alternatives (indicated by a buffer flag), either wait for the
2471 * consumer to get it's job done, or to write a generic message saying
2474 * Since the waiting would need a signal semaphore, we'll skip that for now.
2476 * @returns iprt status code.
2477 * @param pBuffer Pointer to a logger hook buffer.
2479 RTDECL(int) RTLogRegisterHook(PRTLOGGER pLogger
, PRTLOGHOOKBUFFER pBuffer
);
2482 * Deregister a logging hook registered with RTLogRegisterHook().
2484 * @returns iprt status code.
2485 * @param pBuffer Pointer to a logger hook buffer.
2487 RTDECL(int) RTLogDeregisterHook(PRTLOGGER pLogger
, PRTLOGHOOKBUFFER pBuffer
);
2489 #endif /* not implemented yet */
2494 * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
2496 * @param pach What to write.
2497 * @param cb How much to write.
2498 * @remark When linking statically, this function can be replaced by defining your own.
2500 RTDECL(void) RTLogWriteDebugger(const char *pach
, size_t cb
);
2503 * Write log buffer to a user defined output stream (RTLOGDEST_USER).
2505 * @param pach What to write.
2506 * @param cb How much to write.
2507 * @remark When linking statically, this function can be replaced by defining your own.
2509 RTDECL(void) RTLogWriteUser(const char *pach
, size_t cb
);
2512 * Write log buffer to stdout (RTLOGDEST_STDOUT).
2514 * @param pach What to write.
2515 * @param cb How much to write.
2516 * @remark When linking statically, this function can be replaced by defining your own.
2518 RTDECL(void) RTLogWriteStdOut(const char *pach
, size_t cb
);
2521 * Write log buffer to stdout (RTLOGDEST_STDERR).
2523 * @param pach What to write.
2524 * @param cb How much to write.
2525 * @remark When linking statically, this function can be replaced by defining your own.
2527 RTDECL(void) RTLogWriteStdErr(const char *pach
, size_t cb
);
2532 * Prints a formatted string to the backdoor port.
2534 * @returns Number of bytes written.
2535 * @param pszFormat Format string.
2536 * @param ... Optional arguments specified in the format string.
2538 RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat
, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2541 * Prints a formatted string to the backdoor port.
2543 * @returns Number of bytes written.
2544 * @param pszFormat Format string.
2545 * @param args Optional arguments specified in the format string.
2547 RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat
, va_list args
) RT_IPRT_FORMAT_ATTR(1, 0);