VirtualBox

source: vbox/trunk/include/iprt/log.h@ 95897

Last change on this file since 95897 was 94626, checked in by vboxsync, 3 years ago

Runtime/log: Allow setting a custom output interface for the file destination (for encryption), bugref:9955 [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 93.3 KB
Line 
1/** @file
2 * IPRT - Logging.
3 */
4
5/*
6 * Copyright (C) 2006-2022 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_log_h
27#define IPRT_INCLUDED_log_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34#include <iprt/stdarg.h>
35
36RT_C_DECLS_BEGIN
37
38/** @defgroup grp_rt_log RTLog - Logging
39 * @ingroup grp_rt
40 * @{
41 */
42
43/**
44 * IPRT Logging Groups.
45 * (Remember to update RT_LOGGROUP_NAMES!)
46 *
47 * @remark It should be pretty obvious, but just to have
48 * mentioned it, the values are sorted alphabetically (using the
49 * english alphabet) except for _DEFAULT which is always first.
50 *
51 * If anyone might be wondering what the alphabet looks like:
52 * 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
53 */
54typedef enum RTLOGGROUP
55{
56 /** Default logging group. */
57 RTLOGGROUP_DEFAULT,
58 RTLOGGROUP_CRYPTO,
59 RTLOGGROUP_DBG,
60 RTLOGGROUP_DBG_DWARF,
61 RTLOGGROUP_DIR,
62 RTLOGGROUP_FILE,
63 RTLOGGROUP_FS,
64 RTLOGGROUP_FTP,
65 RTLOGGROUP_HTTP,
66 RTLOGGROUP_IOQUEUE,
67 RTLOGGROUP_LDR,
68 RTLOGGROUP_LOCALIPC,
69 RTLOGGROUP_PATH,
70 RTLOGGROUP_PROCESS,
71 RTLOGGROUP_REST,
72 RTLOGGROUP_SYMLINK,
73 RTLOGGROUP_THREAD,
74 RTLOGGROUP_TIME,
75 RTLOGGROUP_TIMER,
76 RTLOGGROUP_VFS,
77 RTLOGGROUP_ZIP = 31,
78 RTLOGGROUP_FIRST_USER = 32
79} RTLOGGROUP;
80
81/** @def RT_LOGGROUP_NAMES
82 * IPRT Logging group names.
83 *
84 * Must correspond 100% to RTLOGGROUP!
85 * Don't forget commas!
86 *
87 * @remark It should be pretty obvious, but just to have
88 * mentioned it, the values are sorted alphabetically (using the
89 * english alphabet) except for _DEFAULT which is always first.
90 *
91 * If anyone might be wondering what the alphabet looks like:
92 * 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
93 *
94 * The RT_XX log group names are placeholders for new modules being added,
95 * to make sure that there always is a total of 32 log group entries.
96 */
97#define RT_LOGGROUP_NAMES \
98 "DEFAULT", \
99 "RT_CRYPTO", \
100 "RT_DBG", \
101 "RT_DBG_DWARF", \
102 "RT_DIR", \
103 "RT_FILE", \
104 "RT_FS", \
105 "RT_FTP", \
106 "RT_HTTP", \
107 "RT_IOQUEUE", \
108 "RT_LDR", \
109 "RT_LOCALIPC", \
110 "RT_PATH", \
111 "RT_PROCESS", \
112 "RT_REST", \
113 "RT_SYMLINK", \
114 "RT_THREAD", \
115 "RT_TIME", \
116 "RT_TIMER", \
117 "RT_VFS", \
118 "RT_20", \
119 "RT_21", \
120 "RT_22", \
121 "RT_23", \
122 "RT_24", \
123 "RT_25", \
124 "RT_26", \
125 "RT_27", \
126 "RT_28", \
127 "RT_29", \
128 "RT_30", \
129 "RT_ZIP"
130
131
132/** @def LOG_GROUP
133 * Active logging group.
134 */
135#ifndef LOG_GROUP
136# define LOG_GROUP RTLOGGROUP_DEFAULT
137#endif
138
139/** @def LOG_FN_FMT
140 * You can use this to specify your desired way of printing __PRETTY_FUNCTION__
141 * if you dislike the default one.
142 */
143#ifndef LOG_FN_FMT
144# define LOG_FN_FMT "%Rfn"
145#endif
146
147#ifdef LOG_INSTANCE
148# error "LOG_INSTANCE is no longer supported."
149#endif
150#ifdef LOG_REL_INSTANCE
151# error "LOG_REL_INSTANCE is no longer supported."
152#endif
153
154/** Logger structure. */
155typedef struct RTLOGGER RTLOGGER;
156/** Pointer to logger structure. */
157typedef RTLOGGER *PRTLOGGER;
158/** Pointer to const logger structure. */
159typedef const RTLOGGER *PCRTLOGGER;
160
161
162/** Pointer to a log buffer descriptor. */
163typedef struct RTLOGBUFFERDESC *PRTLOGBUFFERDESC;
164
165
166/**
167 * Logger phase.
168 *
169 * Used for signalling the log header/footer callback what to do.
170 */
171typedef enum RTLOGPHASE
172{
173 /** Begin of the logging. */
174 RTLOGPHASE_BEGIN = 0,
175 /** End of the logging. */
176 RTLOGPHASE_END,
177 /** Before rotating the log file. */
178 RTLOGPHASE_PREROTATE,
179 /** After rotating the log file. */
180 RTLOGPHASE_POSTROTATE,
181 /** 32-bit type blow up hack. */
182 RTLOGPHASE_32BIT_HACK = 0x7fffffff
183} RTLOGPHASE;
184
185
186/**
187 * Logger function.
188 *
189 * @param pszFormat Format string.
190 * @param ... Optional arguments as specified in the format string.
191 */
192typedef DECLCALLBACKTYPE(void, FNRTLOGGER,(const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(1, 2);
193/** Pointer to logger function. */
194typedef FNRTLOGGER *PFNRTLOGGER;
195
196/**
197 * Custom buffer flushing function.
198 *
199 * @retval true if flushed and the buffer can be reused.
200 * @retval false for switching to the next buffer because an async flush of
201 * @a pBufDesc is still pending. The implementation is responsible for
202 * only returning when the next buffer is ready for reuse, the generic
203 * logger code has no facility to make sure of this.
204 *
205 * @param pLogger Pointer to the logger instance which is to be flushed.
206 * @param pBufDesc The descriptor of the buffer to be flushed.
207 */
208typedef DECLCALLBACKTYPE(bool, FNRTLOGFLUSH,(PRTLOGGER pLogger, PRTLOGBUFFERDESC pBufDesc));
209/** Pointer to flush function. */
210typedef FNRTLOGFLUSH *PFNRTLOGFLUSH;
211
212/**
213 * Header/footer message callback.
214 *
215 * @param pLogger Pointer to the logger instance.
216 * @param pszFormat Format string.
217 * @param ... Optional arguments specified in the format string.
218 */
219typedef DECLCALLBACKTYPE(void, FNRTLOGPHASEMSG,(PRTLOGGER pLogger, const char *pszFormat, ...)) RT_IPRT_FORMAT_ATTR(2, 3);
220/** Pointer to header/footer message callback function. */
221typedef FNRTLOGPHASEMSG *PFNRTLOGPHASEMSG;
222
223/**
224 * Log file header/footer callback.
225 *
226 * @param pLogger Pointer to the logger instance.
227 * @param enmLogPhase Indicates at what time the callback is invoked.
228 * @param pfnLogPhaseMsg Callback for writing the header/footer (RTLogPrintf
229 * and others are out of bounds).
230 */
231typedef DECLCALLBACKTYPE(void, FNRTLOGPHASE,(PRTLOGGER pLogger, RTLOGPHASE enmLogPhase, PFNRTLOGPHASEMSG pfnLogPhaseMsg));
232/** Pointer to log header/footer callback function. */
233typedef FNRTLOGPHASE *PFNRTLOGPHASE;
234
235/**
236 * Custom log prefix callback.
237 *
238 *
239 * @returns The number of chars written.
240 *
241 * @param pLogger Pointer to the logger instance.
242 * @param pchBuf Output buffer pointer.
243 * No need to terminate the output.
244 * @param cchBuf The size of the output buffer.
245 * @param pvUser The user argument.
246 */
247typedef DECLCALLBACKTYPE(size_t, FNRTLOGPREFIX,(PRTLOGGER pLogger, char *pchBuf, size_t cchBuf, void *pvUser));
248/** Pointer to prefix callback function. */
249typedef FNRTLOGPREFIX *PFNRTLOGPREFIX;
250
251
252/** Pointer to a constant log output interface. */
253typedef const struct RTLOGOUTPUTIF *PCRTLOGOUTPUTIF;
254
255/**
256 * Logging output interface.
257 */
258typedef struct RTLOGOUTPUTIF
259{
260 /**
261 * Opens a new log file with the given name.
262 *
263 * @returns IPRT status code.
264 * @param pIf Pointer to this interface.
265 * @param pvUser Opaque user data passed when setting the callbacks.
266 * @param pszFilename The filename to open.
267 * @param fFlags Open flags, combination of RTFILE_O_XXX.
268 */
269 DECLR3CALLBACKMEMBER(int, pfnOpen, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags));
270
271 /**
272 * Closes the currently open file.
273 *
274 * @returns IPRT status code.
275 * @param pIf Pointer to this interface.
276 * @param pvUser Opaque user data passed when setting the callbacks.
277 */
278 DECLR3CALLBACKMEMBER(int, pfnClose, (PCRTLOGOUTPUTIF pIf, void *pvUser));
279
280 /**
281 * Deletes the given file.
282 *
283 * @returns IPRT status code.
284 * @param pIf Pointer to this interface.
285 * @param pvUser Opaque user data passed when setting the callbacks.
286 * @param pszFilename The filename to delete.
287 */
288 DECLR3CALLBACKMEMBER(int, pfnDelete, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename));
289
290 /**
291 * Renames the given file.
292 *
293 * @returns IPRT status code.
294 * @param pIf Pointer to this interface.
295 * @param pvUser Opaque user data passed when setting the callbacks.
296 * @param pszFilenameOld The old filename to rename.
297 * @param pszFilenameNew The new filename.
298 * @param fFlags Flags for the operation, combination of RTFILEMOVE_FLAGS_XXX.
299 */
300 DECLR3CALLBACKMEMBER(int, pfnRename, (PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld,
301 const char *pszFilenameNew, uint32_t fFlags));
302
303 /**
304 * Queries the size of the log file.
305 *
306 * @returns IPRT status code.
307 * @param pIf Pointer to this interface.
308 * @param pvUser Opaque user data passed when setting the callbacks.
309 * @param pcbFile Where to store the file size in bytes on success.
310 */
311 DECLR3CALLBACKMEMBER(int, pfnQuerySize, (PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize));
312
313 /**
314 * Writes data to the log file.
315 *
316 * @returns IPRT status code.
317 * @param pIf Pointer to this interface.
318 * @param pvUser Opaque user data passed when setting the callbacks.
319 * @param pvBuf The data to write.
320 * @param cbWrite Number of bytes to write.
321 * @param pcbWritten Where to store the actual number of bytes written on success.
322 */
323 DECLR3CALLBACKMEMBER(int, pfnWrite, (PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf,
324 size_t cbWrite, size_t *pcbWritten));
325
326 /**
327 * Flushes data to the underlying storage medium.
328 *
329 * @returns IPRT status code.
330 * @param pIf Pointer to this interface.
331 * @param pvUser Opaque user data passed when setting the callbacks.
332 */
333 DECLR3CALLBACKMEMBER(int, pfnFlush, (PCRTLOGOUTPUTIF pIf, void *pvUser));
334} RTLOGOUTPUTIF;
335/** Pointer to a logging output interface. */
336typedef struct RTLOGOUTPUTIF *PRTLOGOUTPUTIF;
337
338
339/**
340 * Auxiliary buffer descriptor.
341 *
342 * This is what we share we ring-3 and use for flushing ring-0 EMT loggers when
343 * we return to ring-3.
344 */
345typedef struct RTLOGBUFFERAUXDESC
346{
347 /** Flush indicator.
348 * Ring-3 sets this if it flushed the buffer, ring-0 clears it again after
349 * writing. */
350 bool volatile fFlushedIndicator;
351 bool afPadding[3];
352 /** Copy of RTLOGBUFFERDESC::offBuf. */
353 uint32_t offBuf;
354} RTLOGBUFFERAUXDESC;
355/** Pointer to auxiliary buffer descriptor. */
356typedef RTLOGBUFFERAUXDESC *PRTLOGBUFFERAUXDESC;
357
358/**
359 * Log buffer desciptor.
360 */
361typedef struct RTLOGBUFFERDESC
362{
363 /** Magic value / eye catcher (RTLOGBUFFERDESC_MAGIC). */
364 uint32_t u32Magic;
365 /** Padding. */
366 uint32_t uReserved;
367 /** The buffer size. */
368 uint32_t cbBuf;
369 /** The current buffer offset. */
370 uint32_t offBuf;
371 /** Pointer to the buffer. */
372 char *pchBuf;
373 /** Pointer to auxiliary desciptor, NULL if not used. */
374 PRTLOGBUFFERAUXDESC pAux;
375} RTLOGBUFFERDESC;
376
377/** RTLOGBUFFERDESC::u32Magic value. (Avram Noam Chomsky) */
378#define RTLOGBUFFERDESC_MAGIC UINT32_C(0x19281207)
379
380/**
381 * The public logger instance part.
382 *
383 * The logger instance is mostly abstract and kept as RTLOGGERINTERNAL within
384 * log.cpp. This public part is at the start of RTLOGGERINTERNAL.
385 */
386struct RTLOGGER
387{
388 /** Magic number (RTLOGGER_MAGIC). */
389 uint32_t u32Magic;
390 /** User value \#1, initialized to zero. */
391 uint32_t u32UserValue1;
392 /** User value \#2, initialized to zero. */
393 uint64_t u64UserValue2;
394 /** User value \#3, initialized to zero. */
395 uint64_t u64UserValue3;
396 /** Pointer to the logger function (used in non-C99 mode only).
397 *
398 * This is actually pointer to a wrapper/stub function which will push a pointer
399 * to the instance pointer onto the stack before jumping to the real logger
400 * function. A very unfortunate hack to work around the missing variadic macro
401 * support in older C++/C standards. (The memory is allocated using
402 * RTMemExecAlloc(), except for agnostic R0 code.) */
403 PFNRTLOGGER pfnLogger;
404#if ARCH_BITS == 32
405 /** Explicit padding. */
406 uint32_t uReserved1;
407#endif
408};
409
410/** RTLOGGER::u32Magic value. (John Rogers Searle) */
411#define RTLOGGER_MAGIC UINT32_C(0x19320731)
412
413/**
414 * Logger flags.
415 */
416typedef enum RTLOGFLAGS
417{
418 /** The logger instance is disabled for normal output. */
419 RTLOGFLAGS_DISABLED = 0x00000001,
420 /** The logger instance is using buffered output. */
421 RTLOGFLAGS_BUFFERED = 0x00000002,
422 /** The logger instance expands LF to CR/LF. */
423 RTLOGFLAGS_USECRLF = 0x00000010,
424 /** Append to the log destination where applicable. */
425 RTLOGFLAGS_APPEND = 0x00000020,
426 /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
427 RTLOGFLAGS_REL_TS = 0x00000040,
428 /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
429 RTLOGFLAGS_DECIMAL_TS = 0x00000080,
430 /** Open the file in write through mode. */
431 RTLOGFLAGS_WRITE_THROUGH = 0x00000100,
432 /** Flush the file to disk when flushing the buffer. */
433 RTLOGFLAGS_FLUSH = 0x00000200,
434 /** Restrict the number of log entries per group. */
435 RTLOGFLAGS_RESTRICT_GROUPS = 0x00000400,
436 /** New lines should be prefixed with the write and read lock counts. */
437 RTLOGFLAGS_PREFIX_LOCK_COUNTS = 0x00008000,
438 /** New lines should be prefixed with the CPU id (ApicID on intel/amd). */
439 RTLOGFLAGS_PREFIX_CPUID = 0x00010000,
440 /** New lines should be prefixed with the native process id. */
441 RTLOGFLAGS_PREFIX_PID = 0x00020000,
442 /** New lines should be prefixed with group flag number causing the output. */
443 RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,
444 /** New lines should be prefixed with group flag name causing the output. */
445 RTLOGFLAGS_PREFIX_FLAG = 0x00080000,
446 /** New lines should be prefixed with group number. */
447 RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,
448 /** New lines should be prefixed with group name. */
449 RTLOGFLAGS_PREFIX_GROUP = 0x00200000,
450 /** New lines should be prefixed with the native thread id. */
451 RTLOGFLAGS_PREFIX_TID = 0x00400000,
452 /** New lines should be prefixed with thread name. */
453 RTLOGFLAGS_PREFIX_THREAD = 0x00800000,
454 /** New lines should be prefixed with data from a custom callback. */
455 RTLOGFLAGS_PREFIX_CUSTOM = 0x01000000,
456 /** New lines should be prefixed with formatted timestamp since program start. */
457 RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
458 /** New lines should be prefixed with formatted timestamp (UCT). */
459 RTLOGFLAGS_PREFIX_TIME = 0x08000000,
460 /** New lines should be prefixed with milliseconds since program start. */
461 RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,
462 /** New lines should be prefixed with timestamp. */
463 RTLOGFLAGS_PREFIX_TSC = 0x20000000,
464 /** New lines should be prefixed with timestamp. */
465 RTLOGFLAGS_PREFIX_TS = 0x40000000,
466 /** The prefix mask. */
467 RTLOGFLAGS_PREFIX_MASK = 0x7dff8000
468} RTLOGFLAGS;
469/** Don't use locking. */
470#define RTLOG_F_NO_LOCKING RT_BIT_64(63)
471/** Mask with all valid log flags (for validation). */
472#define RTLOG_F_VALID_MASK UINT64_C(0x800000007fff87f3)
473
474/**
475 * Logger per group flags.
476 *
477 * @remarks We only use the lower 16 bits here. We'll be combining it with the
478 * group number in a few places.
479 */
480typedef enum RTLOGGRPFLAGS
481{
482 /** Enabled. */
483 RTLOGGRPFLAGS_ENABLED = 0x0001,
484 /** Flow logging. */
485 RTLOGGRPFLAGS_FLOW = 0x0002,
486 /** Warnings logging. */
487 RTLOGGRPFLAGS_WARN = 0x0004,
488 /* 0x0008 for later. */
489 /** Level 1 logging. */
490 RTLOGGRPFLAGS_LEVEL_1 = 0x0010,
491 /** Level 2 logging. */
492 RTLOGGRPFLAGS_LEVEL_2 = 0x0020,
493 /** Level 3 logging. */
494 RTLOGGRPFLAGS_LEVEL_3 = 0x0040,
495 /** Level 4 logging. */
496 RTLOGGRPFLAGS_LEVEL_4 = 0x0080,
497 /** Level 5 logging. */
498 RTLOGGRPFLAGS_LEVEL_5 = 0x0100,
499 /** Level 6 logging. */
500 RTLOGGRPFLAGS_LEVEL_6 = 0x0200,
501 /** Level 7 logging. */
502 RTLOGGRPFLAGS_LEVEL_7 = 0x0400,
503 /** Level 8 logging. */
504 RTLOGGRPFLAGS_LEVEL_8 = 0x0800,
505 /** Level 9 logging. */
506 RTLOGGRPFLAGS_LEVEL_9 = 0x1000,
507 /** Level 10 logging. */
508 RTLOGGRPFLAGS_LEVEL_10 = 0x2000,
509 /** Level 11 logging. */
510 RTLOGGRPFLAGS_LEVEL_11 = 0x4000,
511 /** Level 12 logging. */
512 RTLOGGRPFLAGS_LEVEL_12 = 0x8000,
513
514 /** Restrict the number of log entries. */
515 RTLOGGRPFLAGS_RESTRICT = 0x40000000,
516 /** Blow up the type. */
517 RTLOGGRPFLAGS_32BIT_HACK = 0x7fffffff
518} RTLOGGRPFLAGS;
519
520/**
521 * Logger destination types and flags.
522 */
523typedef enum RTLOGDEST
524{
525 /** Log to file. */
526 RTLOGDEST_FILE = 0x00000001,
527 /** Log to stdout. */
528 RTLOGDEST_STDOUT = 0x00000002,
529 /** Log to stderr. */
530 RTLOGDEST_STDERR = 0x00000004,
531 /** Log to debugger (win32 only). */
532 RTLOGDEST_DEBUGGER = 0x00000008,
533 /** Log to com port. */
534 RTLOGDEST_COM = 0x00000010,
535 /** Log a memory ring buffer. */
536 RTLOGDEST_RINGBUF = 0x00000020,
537 /** Open files with no deny (share read, write, delete) on Windows. */
538 RTLOGDEST_F_NO_DENY = 0x00010000,
539 /** Delay opening the log file, logging to the buffer untill
540 * RTLogClearFileDelayFlag is called. */
541 RTLOGDEST_F_DELAY_FILE = 0x00020000,
542 /** Don't allow changes to the filename or mode of opening it. */
543 RTLOGDEST_FIXED_FILE = 0x01000000,
544 /** Don't allow changing the directory. */
545 RTLOGDEST_FIXED_DIR = 0x02000000,
546 /** Just a dummy flag to be used when no other flag applies. */
547 RTLOGDEST_DUMMY = 0x20000000,
548 /** Log to a user defined output stream. */
549 RTLOGDEST_USER = 0x40000000
550} RTLOGDEST;
551/** Valid log destinations. */
552#define RTLOG_DST_VALID_MASK UINT32_C(0x6303003f)
553/** Log destinations that can be changed via RTLogChangeDestinations. */
554#define RTLOG_DST_CHANGE_MASK UINT32_C(0x4000001e)
555
556
557#ifdef DOXYGEN_RUNNING
558# define LOG_DISABLED
559# define LOG_ENABLED
560# define LOG_ENABLE_FLOW
561#endif
562
563/** @def LOG_DISABLED
564 * Use this compile time define to disable all logging macros. It can
565 * be overridden for each of the logging macros by the LOG_ENABLE*
566 * compile time defines.
567 */
568
569/** @def LOG_ENABLED
570 * Use this compile time define to enable logging when not in debug mode
571 * or LOG_DISABLED is set.
572 * This will enable Log() only.
573 */
574
575/** @def LOG_ENABLE_FLOW
576 * Use this compile time define to enable flow logging when not in
577 * debug mode or LOG_DISABLED is defined.
578 * This will enable LogFlow() only.
579 */
580
581/*
582 * Determine whether logging is enabled and forcefully normalize the indicators.
583 */
584#if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
585# undef LOG_DISABLED
586# undef LOG_ENABLED
587# define LOG_ENABLED
588#else
589# undef LOG_ENABLED
590# undef LOG_DISABLED
591# define LOG_DISABLED
592#endif
593
594
595/** @def LOG_USE_C99
596 * Governs the use of variadic macros.
597 */
598#ifndef LOG_USE_C99
599# if !defined(RT_OS_OS2)
600# define LOG_USE_C99
601# endif
602#endif
603
604
605/** @name Macros for checking whether a log level is enabled.
606 * @{ */
607/** @def LogIsItEnabled
608 * Checks whether the specified logging group is enabled or not.
609 */
610#ifdef LOG_ENABLED
611# define LogIsItEnabled(a_fFlags, a_iGroup) ( RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
612#else
613# define LogIsItEnabled(a_fFlags, a_iGroup) (false)
614#endif
615
616/** @def LogIsEnabled
617 * Checks whether level 1 logging is enabled.
618 */
619#define LogIsEnabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
620
621/** @def LogIs2Enabled
622 * Checks whether level 2 logging is enabled.
623 */
624#define LogIs2Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
625
626/** @def LogIs3Enabled
627 * Checks whether level 3 logging is enabled.
628 */
629#define LogIs3Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
630
631/** @def LogIs4Enabled
632 * Checks whether level 4 logging is enabled.
633 */
634#define LogIs4Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
635
636/** @def LogIs5Enabled
637 * Checks whether level 5 logging is enabled.
638 */
639#define LogIs5Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
640
641/** @def LogIs6Enabled
642 * Checks whether level 6 logging is enabled.
643 */
644#define LogIs6Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
645
646/** @def LogIs7Enabled
647 * Checks whether level 7 logging is enabled.
648 */
649#define LogIs7Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
650
651/** @def LogIs8Enabled
652 * Checks whether level 8 logging is enabled.
653 */
654#define LogIs8Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
655
656/** @def LogIs9Enabled
657 * Checks whether level 9 logging is enabled.
658 */
659#define LogIs9Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
660
661/** @def LogIs10Enabled
662 * Checks whether level 10 logging is enabled.
663 */
664#define LogIs10Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
665
666/** @def LogIs11Enabled
667 * Checks whether level 11 logging is enabled.
668 */
669#define LogIs11Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
670
671/** @def LogIs12Enabled
672 * Checks whether level 12 logging is enabled.
673 */
674#define LogIs12Enabled() LogIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
675
676/** @def LogIsFlowEnabled
677 * Checks whether execution flow logging is enabled.
678 */
679#define LogIsFlowEnabled() LogIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
680
681/** @def LogIsWarnEnabled
682 * Checks whether execution flow logging is enabled.
683 */
684#define LogIsWarnEnabled() LogIsItEnabled(RTLOGGRPFLAGS_WARN, LOG_GROUP)
685/** @} */
686
687
688/** @def LogIt
689 * Write to specific logger if group enabled.
690 */
691#ifdef LOG_ENABLED
692# if defined(LOG_USE_C99)
693# define _LogRemoveParentheseis(...) __VA_ARGS__
694# define _LogIt(a_fFlags, a_iGroup, ...) \
695 do \
696 { \
697 PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
698 if (RT_LIKELY(!LogIt_pLogger)) \
699 { /* likely */ } \
700 else \
701 RTLogLoggerEx(LogIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
702 } while (0)
703# define LogIt(a_fFlags, a_iGroup, fmtargs) _LogIt(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
704# define _LogItAlways(a_fFlags, a_iGroup, ...) RTLogLoggerEx(NULL, a_fFlags, UINT32_MAX, __VA_ARGS__)
705# define LogItAlways(a_fFlags, a_iGroup, fmtargs) _LogItAlways(a_fFlags, a_iGroup, _LogRemoveParentheseis fmtargs)
706 /** @todo invent a flag or something for skipping the group check so we can pass iGroup. LogItAlways. */
707# else
708# define LogIt(a_fFlags, a_iGroup, fmtargs) \
709 do \
710 { \
711 PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
712 if (RT_LIKELY(!LogIt_pLogger)) \
713 { /* likely */ } \
714 else \
715 { \
716 LogIt_pLogger->pfnLogger fmtargs; \
717 } \
718 } while (0)
719# define LogItAlways(a_fFlags, a_iGroup, fmtargs) \
720 do \
721 { \
722 PRTLOGGER LogIt_pLogger = RTLogDefaultInstanceEx(RT_MAKE_U32(0, UINT16_MAX)); \
723 if (LogIt_pLogger) \
724 LogIt_pLogger->pfnLogger fmtargs; \
725 } while (0)
726# endif
727#else
728# define LogIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
729# define LogItAlways(a_fFlags, a_iGroup, fmtargs) do { } while (0)
730# if defined(LOG_USE_C99)
731# define _LogRemoveParentheseis(...) __VA_ARGS__
732# define _LogIt(a_fFlags, a_iGroup, ...) do { } while (0)
733# define _LogItAlways(a_fFlags, a_iGroup, ...) do { } while (0)
734# endif
735#endif
736
737
738/** @name Basic logging macros
739 * @{ */
740/** @def Log
741 * Level 1 logging that works regardless of the group settings.
742 */
743#define LogAlways(a) LogItAlways(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
744
745/** @def Log
746 * Level 1 logging.
747 */
748#define Log(a) LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
749
750/** @def Log2
751 * Level 2 logging.
752 */
753#define Log2(a) LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
754
755/** @def Log3
756 * Level 3 logging.
757 */
758#define Log3(a) LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
759
760/** @def Log4
761 * Level 4 logging.
762 */
763#define Log4(a) LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
764
765/** @def Log5
766 * Level 5 logging.
767 */
768#define Log5(a) LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
769
770/** @def Log6
771 * Level 6 logging.
772 */
773#define Log6(a) LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
774
775/** @def Log7
776 * Level 7 logging.
777 */
778#define Log7(a) LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
779
780/** @def Log8
781 * Level 8 logging.
782 */
783#define Log8(a) LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
784
785/** @def Log9
786 * Level 9 logging.
787 */
788#define Log9(a) LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
789
790/** @def Log10
791 * Level 10 logging.
792 */
793#define Log10(a) LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
794
795/** @def Log11
796 * Level 11 logging.
797 */
798#define Log11(a) LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
799
800/** @def Log12
801 * Level 12 logging.
802 */
803#define Log12(a) LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
804
805/** @def LogFlow
806 * Logging of execution flow.
807 */
808#define LogFlow(a) LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
809
810/** @def LogWarn
811 * Logging of warnings.
812 */
813#define LogWarn(a) LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
814/** @} */
815
816
817/** @name Logging macros prefixing the current function name.
818 * @{ */
819/** @def LogFunc
820 * Level 1 logging inside C/C++ functions.
821 *
822 * Prepends the given log message with the function name followed by a
823 * semicolon and space.
824 *
825 * @param a Log message in format <tt>("string\n" [, args])</tt>.
826 */
827#ifdef LOG_USE_C99
828# define LogFunc(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
829#else
830# define LogFunc(a) do { Log((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
831#endif
832
833/** @def Log2Func
834 * Level 2 logging inside C/C++ functions.
835 *
836 * Prepends the given log message with the function name followed by a
837 * semicolon and space.
838 *
839 * @param a Log message in format <tt>("string\n" [, args])</tt>.
840 */
841#ifdef LOG_USE_C99
842# define Log2Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
843#else
844# define Log2Func(a) do { Log2((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
845#endif
846
847/** @def Log3Func
848 * Level 3 logging inside C/C++ functions.
849 *
850 * Prepends the given log message with the function name followed by a
851 * semicolon and space.
852 *
853 * @param a Log message in format <tt>("string\n" [, args])</tt>.
854 */
855#ifdef LOG_USE_C99
856# define Log3Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
857#else
858# define Log3Func(a) do { Log3((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
859#endif
860
861/** @def Log4Func
862 * Level 4 logging inside C/C++ functions.
863 *
864 * Prepends the given log message with the function name followed by a
865 * semicolon and space.
866 *
867 * @param a Log message in format <tt>("string\n" [, args])</tt>.
868 */
869#ifdef LOG_USE_C99
870# define Log4Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
871#else
872# define Log4Func(a) do { Log4((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
873#endif
874
875/** @def Log5Func
876 * Level 5 logging inside C/C++ functions.
877 *
878 * Prepends the given log message with the function name followed by a
879 * semicolon and space.
880 *
881 * @param a Log message in format <tt>("string\n" [, args])</tt>.
882 */
883#ifdef LOG_USE_C99
884# define Log5Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
885#else
886# define Log5Func(a) do { Log5((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
887#endif
888
889/** @def Log6Func
890 * Level 6 logging inside C/C++ functions.
891 *
892 * Prepends the given log message with the function name followed by a
893 * semicolon and space.
894 *
895 * @param a Log message in format <tt>("string\n" [, args])</tt>.
896 */
897#ifdef LOG_USE_C99
898# define Log6Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
899#else
900# define Log6Func(a) do { Log6((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
901#endif
902
903/** @def Log7Func
904 * Level 7 logging inside C/C++ functions.
905 *
906 * Prepends the given log message with the function name followed by a
907 * semicolon and space.
908 *
909 * @param a Log message in format <tt>("string\n" [, args])</tt>.
910 */
911#ifdef LOG_USE_C99
912# define Log7Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
913#else
914# define Log7Func(a) do { Log7((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
915#endif
916
917/** @def Log8Func
918 * Level 8 logging inside C/C++ functions.
919 *
920 * Prepends the given log message with the function name followed by a
921 * semicolon and space.
922 *
923 * @param a Log message in format <tt>("string\n" [, args])</tt>.
924 */
925#ifdef LOG_USE_C99
926# define Log8Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
927#else
928# define Log8Func(a) do { Log8((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
929#endif
930
931/** @def Log9Func
932 * Level 9 logging inside C/C++ functions.
933 *
934 * Prepends the given log message with the function name followed by a
935 * semicolon and space.
936 *
937 * @param a Log message in format <tt>("string\n" [, args])</tt>.
938 */
939#ifdef LOG_USE_C99
940# define Log9Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
941#else
942# define Log9Func(a) do { Log9((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
943#endif
944
945/** @def Log10Func
946 * Level 10 logging inside C/C++ functions.
947 *
948 * Prepends the given log message with the function name followed by a
949 * semicolon and space.
950 *
951 * @param a Log message in format <tt>("string\n" [, args])</tt>.
952 */
953#ifdef LOG_USE_C99
954# define Log10Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
955#else
956# define Log10Func(a) do { Log10((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
957#endif
958
959/** @def Log11Func
960 * Level 11 logging inside C/C++ functions.
961 *
962 * Prepends the given log message with the function name followed by a
963 * semicolon and space.
964 *
965 * @param a Log message in format <tt>("string\n" [, args])</tt>.
966 */
967#ifdef LOG_USE_C99
968# define Log11Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
969#else
970# define Log11Func(a) do { Log11((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
971#endif
972
973/** @def Log12Func
974 * Level 12 logging inside C/C++ functions.
975 *
976 * Prepends the given log message with the function name followed by a
977 * semicolon and space.
978 *
979 * @param a Log message in format <tt>("string\n" [, args])</tt>.
980 */
981#ifdef LOG_USE_C99
982# define Log12Func(a) _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
983#else
984# define Log12Func(a) do { Log12((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
985#endif
986
987/** @def LogFlowFunc
988 * Macro to log the execution flow inside C/C++ functions.
989 *
990 * Prepends the given log message with the function name followed by
991 * a semicolon and space.
992 *
993 * @param a Log message in format <tt>("string\n" [, args])</tt>.
994 */
995#ifdef LOG_USE_C99
996# define LogFlowFunc(a) \
997 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
998#else
999# define LogFlowFunc(a) \
1000 do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
1001#endif
1002
1003/** @def LogWarnFunc
1004 * Macro to log a warning inside C/C++ functions.
1005 *
1006 * Prepends the given log message with the function name followed by
1007 * a semicolon and space.
1008 *
1009 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1010 */
1011#ifdef LOG_USE_C99
1012# define LogWarnFunc(a) \
1013 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1014#else
1015# define LogWarnFunc(a) \
1016 do { LogFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
1017#endif
1018/** @} */
1019
1020
1021/** @name Logging macros prefixing the this pointer value and method name.
1022 * @{ */
1023
1024/** @def LogThisFunc
1025 * Level 1 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>.
1028 */
1029#ifdef LOG_USE_C99
1030# define LogThisFunc(a) \
1031 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1032#else
1033# define LogThisFunc(a) do { Log(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
1034#endif
1035
1036/** @def Log2ThisFunc
1037 * Level 2 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>.
1040 */
1041#ifdef LOG_USE_C99
1042# define Log2ThisFunc(a) \
1043 _LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1044#else
1045# define Log2ThisFunc(a) do { Log2(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log2(a); } while (0)
1046#endif
1047
1048/** @def Log3ThisFunc
1049 * Level 3 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>.
1052 */
1053#ifdef LOG_USE_C99
1054# define Log3ThisFunc(a) \
1055 _LogIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1056#else
1057# define Log3ThisFunc(a) do { Log3(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log3(a); } while (0)
1058#endif
1059
1060/** @def Log4ThisFunc
1061 * Level 4 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>.
1064 */
1065#ifdef LOG_USE_C99
1066# define Log4ThisFunc(a) \
1067 _LogIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1068#else
1069# define Log4ThisFunc(a) do { Log4(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log4(a); } while (0)
1070#endif
1071
1072/** @def Log5ThisFunc
1073 * Level 5 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>.
1076 */
1077#ifdef LOG_USE_C99
1078# define Log5ThisFunc(a) \
1079 _LogIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1080#else
1081# define Log5ThisFunc(a) do { Log5(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log5(a); } while (0)
1082#endif
1083
1084/** @def Log6ThisFunc
1085 * Level 6 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>.
1088 */
1089#ifdef LOG_USE_C99
1090# define Log6ThisFunc(a) \
1091 _LogIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1092#else
1093# define Log6ThisFunc(a) do { Log6(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log6(a); } while (0)
1094#endif
1095
1096/** @def Log7ThisFunc
1097 * Level 7 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>.
1100 */
1101#ifdef LOG_USE_C99
1102# define Log7ThisFunc(a) \
1103 _LogIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1104#else
1105# define Log7ThisFunc(a) do { Log7(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log7(a); } while (0)
1106#endif
1107
1108/** @def Log8ThisFunc
1109 * Level 8 logging inside a C++ non-static method, with object pointer and
1110 * method name prefixed to the given message.
1111 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1112 */
1113#ifdef LOG_USE_C99
1114# define Log8ThisFunc(a) \
1115 _LogIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1116#else
1117# define Log8ThisFunc(a) do { Log8(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log8(a); } while (0)
1118#endif
1119
1120/** @def Log9ThisFunc
1121 * Level 9 logging inside a C++ non-static method, with object pointer and
1122 * method name prefixed to the given message.
1123 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1124 */
1125#ifdef LOG_USE_C99
1126# define Log9ThisFunc(a) \
1127 _LogIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1128#else
1129# define Log9ThisFunc(a) do { Log9(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log9(a); } while (0)
1130#endif
1131
1132/** @def Log10ThisFunc
1133 * Level 10 logging inside a C++ non-static method, with object pointer and
1134 * method name prefixed to the given message.
1135 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1136 */
1137#ifdef LOG_USE_C99
1138# define Log10ThisFunc(a) \
1139 _LogIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1140#else
1141# define Log10ThisFunc(a) do { Log10(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log10(a); } while (0)
1142#endif
1143
1144/** @def Log11ThisFunc
1145 * Level 11 logging inside a C++ non-static method, with object pointer and
1146 * method name prefixed to the given message.
1147 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1148 */
1149#ifdef LOG_USE_C99
1150# define Log11ThisFunc(a) \
1151 _LogIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1152#else
1153# define Log11ThisFunc(a) do { Log11(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log11(a); } while (0)
1154#endif
1155
1156/** @def Log12ThisFunc
1157 * Level 12 logging inside a C++ non-static method, with object pointer and
1158 * method name prefixed to the given message.
1159 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1160 */
1161#ifdef LOG_USE_C99
1162# define Log12ThisFunc(a) \
1163 _LogIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1164#else
1165# define Log12ThisFunc(a) do { Log12(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log12(a); } while (0)
1166#endif
1167
1168/** @def LogFlowThisFunc
1169 * Flow level logging inside a C++ non-static method, with object pointer and
1170 * method name prefixed to the given message.
1171 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1172 */
1173#ifdef LOG_USE_C99
1174# define LogFlowThisFunc(a) \
1175 _LogIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1176#else
1177# define LogFlowThisFunc(a) do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogFlow(a); } while (0)
1178#endif
1179
1180/** @def LogWarnThisFunc
1181 * Warning level logging inside a C++ non-static method, with object pointer and
1182 * method name prefixed to the given message.
1183 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1184 */
1185#ifdef LOG_USE_C99
1186# define LogWarnThisFunc(a) \
1187 _LogIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1188#else
1189# define LogWarnThisFunc(a) do { LogWarn(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogWarn(a); } while (0)
1190#endif
1191/** @} */
1192
1193
1194/** @name Misc Logging Macros
1195 * @{ */
1196
1197/** @def Log1Warning
1198 * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
1199 *
1200 * @param a Custom log message in format <tt>("string\n" [, args])</tt>.
1201 */
1202#if defined(LOG_USE_C99)
1203# define Log1Warning(a) _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a )
1204#else
1205# define Log1Warning(a) do { Log(("WARNING! ")); Log(a); } while (0)
1206#endif
1207
1208/** @def Log1WarningFunc
1209 * The same as LogWarning(), but prepents the log message with the function name.
1210 *
1211 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1212 */
1213#ifdef LOG_USE_C99
1214# define Log1WarningFunc(a) \
1215 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1216#else
1217# define Log1WarningFunc(a) \
1218 do { Log((LOG_FN_FMT ": WARNING! ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
1219#endif
1220
1221/** @def Log1WarningThisFunc
1222 * The same as LogWarningFunc() but for class functions (methods): the resulting
1223 * log line is additionally prepended with a hex value of |this| pointer.
1224 *
1225 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1226 */
1227#ifdef LOG_USE_C99
1228# define Log1WarningThisFunc(a) \
1229 _LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1230#else
1231# define Log1WarningThisFunc(a) \
1232 do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); Log(a); } while (0)
1233#endif
1234
1235
1236/** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1237#define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
1238
1239/** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */
1240#define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
1241
1242/** Shortcut to |LogFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1243#define LogFlowFuncLeaveRC(rc) LogFlowFunc(("LEAVE: %Rrc\n", (rc)))
1244
1245/** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1246#define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
1247
1248/** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1249#define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
1250
1251
1252/** @def LogObjRefCnt
1253 * Helper macro to print the current reference count of the given COM object
1254 * to the log file.
1255 *
1256 * @param pObj Pointer to the object in question (must be a pointer to an
1257 * IUnknown subclass or simply define COM-style AddRef() and
1258 * Release() methods)
1259 */
1260#define LogObjRefCnt(pObj) \
1261 do { \
1262 if (LogIsFlowEnabled()) \
1263 { \
1264 int cRefsForLog = (pObj)->AddRef(); \
1265 LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), cRefsForLog - 1)); \
1266 (pObj)->Release(); \
1267 } \
1268 } while (0)
1269/** @} */
1270
1271
1272
1273/** @name Passing Function Call Position When Logging.
1274 *
1275 * This is a little bit ugly as we have to omit the comma before the
1276 * position parameters so that we don't inccur any overhead in non-logging
1277 * builds (!defined(LOG_ENABLED).
1278 *
1279 * @{ */
1280/** Source position for passing to a function call. */
1281#ifdef LOG_ENABLED
1282# define RTLOG_COMMA_SRC_POS , __FILE__, __LINE__, RT_GCC_EXTENSION __PRETTY_FUNCTION__
1283#else
1284# define RTLOG_COMMA_SRC_POS RT_NOTHING
1285#endif
1286/** Source position declaration. */
1287#ifdef LOG_ENABLED
1288# define RTLOG_COMMA_SRC_POS_DECL , const char *pszFile, unsigned iLine, const char *pszFunction
1289#else
1290# define RTLOG_COMMA_SRC_POS_DECL RT_NOTHING
1291#endif
1292/** Source position arguments. */
1293#ifdef LOG_ENABLED
1294# define RTLOG_COMMA_SRC_POS_ARGS , pszFile, iLine, pszFunction
1295#else
1296# define RTLOG_COMMA_SRC_POS_ARGS RT_NOTHING
1297#endif
1298/** Applies NOREF() to the source position arguments. */
1299#ifdef LOG_ENABLED
1300# define RTLOG_SRC_POS_NOREF() do { NOREF(pszFile); NOREF(iLine); NOREF(pszFunction); } while (0)
1301#else
1302# define RTLOG_SRC_POS_NOREF() do { } while (0)
1303#endif
1304/** @} */
1305
1306
1307
1308/** @defgroup grp_rt_log_rel Release Logging
1309 * @{
1310 */
1311
1312#ifdef DOXYGEN_RUNNING
1313# define RTLOG_REL_DISABLED
1314# define RTLOG_REL_ENABLED
1315#endif
1316
1317/** @def RTLOG_REL_DISABLED
1318 * Use this compile time define to disable all release logging
1319 * macros.
1320 */
1321
1322/** @def RTLOG_REL_ENABLED
1323 * Use this compile time define to override RTLOG_REL_DISABLE.
1324 */
1325
1326/*
1327 * Determine whether release logging is enabled and forcefully normalize the indicators.
1328 */
1329#if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED)
1330# undef RTLOG_REL_DISABLED
1331# undef RTLOG_REL_ENABLED
1332# define RTLOG_REL_ENABLED
1333#else
1334# undef RTLOG_REL_ENABLED
1335# undef RTLOG_REL_DISABLED
1336# define RTLOG_REL_DISABLED
1337#endif
1338
1339/** @name Macros for checking whether a release log level is enabled.
1340 * @{ */
1341/** @def LogRelIsItEnabled
1342 * Checks whether the specified release logging group is enabled or not.
1343 */
1344#define LogRelIsItEnabled(a_fFlags, a_iGroup) ( RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)) != NULL )
1345
1346/** @def LogRelIsEnabled
1347 * Checks whether level 1 release logging is enabled.
1348 */
1349#define LogRelIsEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
1350
1351/** @def LogRelIs2Enabled
1352 * Checks whether level 2 release logging is enabled.
1353 */
1354#define LogRelIs2Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
1355
1356/** @def LogRelIs3Enabled
1357 * Checks whether level 3 release logging is enabled.
1358 */
1359#define LogRelIs3Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
1360
1361/** @def LogRelIs4Enabled
1362 * Checks whether level 4 release logging is enabled.
1363 */
1364#define LogRelIs4Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
1365
1366/** @def LogRelIs5Enabled
1367 * Checks whether level 5 release logging is enabled.
1368 */
1369#define LogRelIs5Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
1370
1371/** @def LogRelIs6Enabled
1372 * Checks whether level 6 release logging is enabled.
1373 */
1374#define LogRelIs6Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
1375
1376/** @def LogRelIs7Enabled
1377 * Checks whether level 7 release logging is enabled.
1378 */
1379#define LogRelIs7Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP)
1380
1381/** @def LogRelIs8Enabled
1382 * Checks whether level 8 release logging is enabled.
1383 */
1384#define LogRelIs8Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP)
1385
1386/** @def LogRelIs2Enabled
1387 * Checks whether level 9 release logging is enabled.
1388 */
1389#define LogRelIs9Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP)
1390
1391/** @def LogRelIs10Enabled
1392 * Checks whether level 10 release logging is enabled.
1393 */
1394#define LogRelIs10Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP)
1395
1396/** @def LogRelIs11Enabled
1397 * Checks whether level 10 release logging is enabled.
1398 */
1399#define LogRelIs11Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP)
1400
1401/** @def LogRelIs12Enabled
1402 * Checks whether level 12 release logging is enabled.
1403 */
1404#define LogRelIs12Enabled() LogRelIsItEnabled(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP)
1405
1406/** @def LogRelIsFlowEnabled
1407 * Checks whether execution flow release logging is enabled.
1408 */
1409#define LogRelIsFlowEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1410
1411/** @def LogRelIsWarnEnabled
1412 * Checks whether warning level release logging is enabled.
1413 */
1414#define LogRelIsWarnEnabled() LogRelIsItEnabled(RTLOGGRPFLAGS_FLOW, LOG_GROUP)
1415/** @} */
1416
1417
1418/** @def LogRelIt
1419 * Write to specific logger if group enabled.
1420 */
1421/** @def LogRelItLikely
1422 * Write to specific logger if group enabled, assuming it likely it is enabled.
1423 */
1424/** @def LogRelMaxIt
1425 * Write to specific logger if group enabled and at less than a_cMax messages
1426 * have hit the log. Uses a static variable to count.
1427 */
1428#ifdef RTLOG_REL_ENABLED
1429# if defined(LOG_USE_C99)
1430# define _LogRelRemoveParentheseis(...) __VA_ARGS__
1431# define _LogRelIt(a_fFlags, a_iGroup, ...) \
1432 do \
1433 { \
1434 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1435 if (RT_LIKELY(!LogRelIt_pLogger)) \
1436 { /* likely */ } \
1437 else \
1438 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1439 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1440 } while (0)
1441# define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1442 _LogRelIt(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1443# define _LogRelItLikely(a_fFlags, a_iGroup, ...) \
1444 do \
1445 { \
1446 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1447 if (LogRelIt_pLogger) \
1448 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1449 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1450 } while (0)
1451# define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1452 _LogRelItLikely(a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1453# define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) \
1454 do \
1455 { \
1456 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1457 if (LogRelIt_pLogger) \
1458 { \
1459 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1460 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1461 { \
1462 s_LogRelMaxIt_cLogged++; \
1463 RTLogLoggerEx(LogRelIt_pLogger, a_fFlags, a_iGroup, __VA_ARGS__); \
1464 } \
1465 } \
1466 _LogIt(a_fFlags, a_iGroup, __VA_ARGS__); \
1467 } while (0)
1468# define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1469 _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, _LogRelRemoveParentheseis fmtargs)
1470# else
1471# define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) \
1472 do \
1473 { \
1474 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1475 if (LogRelIt_pLogger) \
1476 { \
1477 LogRelIt_pLogger->pfnLogger fmtargs; \
1478 } \
1479 LogIt(a_fFlags, a_iGroup, fmtargs); \
1480 } while (0)
1481# define LogRelIt(a_fFlags, a_iGroup, fmtargs) \
1482 do \
1483 { \
1484 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1485 if (RT_LIKELY(!LogRelIt_pLogger)) \
1486 { /* likely */ } \
1487 else \
1488 { \
1489 LogRelIt_pLogger->pfnLogger fmtargs; \
1490 } \
1491 LogIt(a_fFlags, a_iGroup, fmtargs); \
1492 } while (0)
1493# define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) \
1494 do \
1495 { \
1496 PRTLOGGER LogRelIt_pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(a_fFlags, a_iGroup)); \
1497 if (LogRelIt_pLogger) \
1498 { \
1499 static uint32_t s_LogRelMaxIt_cLogged = 0; \
1500 if (s_LogRelMaxIt_cLogged < (a_cMax)) \
1501 { \
1502 s_LogRelMaxIt_cLogged++; \
1503 LogRelIt_pLogger->pfnLogger fmtargs; \
1504 } \
1505 } \
1506 LogIt(a_fFlags, a_iGroup, fmtargs); \
1507 } while (0)
1508# endif
1509#else /* !RTLOG_REL_ENABLED */
1510# define LogRelIt(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1511# define LogRelItLikely(a_fFlags, a_iGroup, fmtargs) do { } while (0)
1512# define LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, fmtargs) do { } while (0)
1513# if defined(LOG_USE_C99)
1514# define _LogRelRemoveParentheseis(...) __VA_ARGS__
1515# define _LogRelIt(a_fFlags, a_iGroup, ...) do { } while (0)
1516# define _LogRelItLikely(a_fFlags, a_iGroup, ...) do { } while (0)
1517# define _LogRelMaxIt(a_cMax, a_fFlags, a_iGroup, ...) do { } while (0)
1518# endif
1519#endif /* !RTLOG_REL_ENABLED */
1520
1521
1522/** @name Basic release logging macros
1523 * @{ */
1524/** @def LogRel
1525 * Level 1 release logging.
1526 */
1527#define LogRel(a) LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1528
1529/** @def LogRel2
1530 * Level 2 release logging.
1531 */
1532#define LogRel2(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1533
1534/** @def LogRel3
1535 * Level 3 release logging.
1536 */
1537#define LogRel3(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1538
1539/** @def LogRel4
1540 * Level 4 release logging.
1541 */
1542#define LogRel4(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1543
1544/** @def LogRel5
1545 * Level 5 release logging.
1546 */
1547#define LogRel5(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1548
1549/** @def LogRel6
1550 * Level 6 release logging.
1551 */
1552#define LogRel6(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1553
1554/** @def LogRel7
1555 * Level 7 release logging.
1556 */
1557#define LogRel7(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1558
1559/** @def LogRel8
1560 * Level 8 release logging.
1561 */
1562#define LogRel8(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1563
1564/** @def LogRel9
1565 * Level 9 release logging.
1566 */
1567#define LogRel9(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1568
1569/** @def LogRel10
1570 * Level 10 release logging.
1571 */
1572#define LogRel10(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1573
1574/** @def LogRel11
1575 * Level 11 release logging.
1576 */
1577#define LogRel11(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1578
1579/** @def LogRel12
1580 * Level 12 release logging.
1581 */
1582#define LogRel12(a) LogRelIt(RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1583
1584/** @def LogRelFlow
1585 * Logging of execution flow.
1586 */
1587#define LogRelFlow(a) LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1588
1589/** @def LogRelWarn
1590 * Warning level release logging.
1591 */
1592#define LogRelWarn(a) LogRelIt(RTLOGGRPFLAGS_WARN, LOG_GROUP, a)
1593/** @} */
1594
1595
1596
1597/** @name Basic release logging macros with local max
1598 * @{ */
1599/** @def LogRelMax
1600 * Level 1 release logging with a max number of log entries.
1601 */
1602#define LogRelMax(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
1603
1604/** @def LogRelMax2
1605 * Level 2 release logging with a max number of log entries.
1606 */
1607#define LogRelMax2(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
1608
1609/** @def LogRelMax3
1610 * Level 3 release logging with a max number of log entries.
1611 */
1612#define LogRelMax3(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
1613
1614/** @def LogRelMax4
1615 * Level 4 release logging with a max number of log entries.
1616 */
1617#define LogRelMax4(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
1618
1619/** @def LogRelMax5
1620 * Level 5 release logging with a max number of log entries.
1621 */
1622#define LogRelMax5(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
1623
1624/** @def LogRelMax6
1625 * Level 6 release logging with a max number of log entries.
1626 */
1627#define LogRelMax6(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
1628
1629/** @def LogRelMax7
1630 * Level 7 release logging with a max number of log entries.
1631 */
1632#define LogRelMax7(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_7, LOG_GROUP, a)
1633
1634/** @def LogRelMax8
1635 * Level 8 release logging with a max number of log entries.
1636 */
1637#define LogRelMax8(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_8, LOG_GROUP, a)
1638
1639/** @def LogRelMax9
1640 * Level 9 release logging with a max number of log entries.
1641 */
1642#define LogRelMax9(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_9, LOG_GROUP, a)
1643
1644/** @def LogRelMax10
1645 * Level 10 release logging with a max number of log entries.
1646 */
1647#define LogRelMax10(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_10, LOG_GROUP, a)
1648
1649/** @def LogRelMax11
1650 * Level 11 release logging with a max number of log entries.
1651 */
1652#define LogRelMax11(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_11, LOG_GROUP, a)
1653
1654/** @def LogRelMax12
1655 * Level 12 release logging with a max number of log entries.
1656 */
1657#define LogRelMax12(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_12, LOG_GROUP, a)
1658
1659/** @def LogRelMaxFlow
1660 * Logging of execution flow with a max number of log entries.
1661 */
1662#define LogRelMaxFlow(a_cMax, a) LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
1663/** @} */
1664
1665
1666/** @name Release logging macros prefixing the current function name.
1667 * @{ */
1668
1669/** @def LogRelFunc
1670 * Release logging. Prepends the given log message with the function name
1671 * followed by a semicolon and space.
1672 */
1673#ifdef LOG_USE_C99
1674# define LogRelFunc(a) \
1675 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1676#else
1677# define LogRelFunc(a) do { LogRel((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1678#endif
1679
1680/** @def LogRelFlowFunc
1681 * Release logging. Macro to log the execution flow inside C/C++ functions.
1682 *
1683 * Prepends the given log message with the function name followed by
1684 * a semicolon and space.
1685 *
1686 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1687 */
1688#ifdef LOG_USE_C99
1689# define LogRelFlowFunc(a) _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1690#else
1691# define LogRelFlowFunc(a) do { LogRelFlow((LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1692#endif
1693
1694/** @def LogRelMaxFunc
1695 * Release logging. Prepends the given log message with the function name
1696 * followed by a semicolon and space.
1697 */
1698#ifdef LOG_USE_C99
1699# define LogRelMaxFunc(a_cMax, a) \
1700 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1701#else
1702# define LogRelMaxFunc(a_cMax, a) \
1703 do { LogRelMax(a_cMax, (LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1704#endif
1705
1706/** @def LogRelMaxFlowFunc
1707 * Release logging. Macro to log the execution flow inside C/C++ functions.
1708 *
1709 * Prepends the given log message with the function name followed by
1710 * a semicolon and space.
1711 *
1712 * @param a_cMax Max number of times this should hit the log.
1713 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1714 */
1715#ifdef LOG_USE_C99
1716# define LogRelMaxFlowFunc(a_cMax, a) \
1717 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1718#else
1719# define LogRelMaxFlowFunc(a_cMax, a) \
1720 do { LogRelMaxFlow(a_cMax, (LOG_FN_FMT ": ", RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a_cMax, a); } while (0)
1721#endif
1722
1723/** @} */
1724
1725
1726/** @name Release Logging macros prefixing the this pointer value and method name.
1727 * @{ */
1728
1729/** @def LogRelThisFunc
1730 * The same as LogRelFunc but for class functions (methods): the resulting log
1731 * line is additionally prepended with a hex value of |this| pointer.
1732 */
1733#ifdef LOG_USE_C99
1734# define LogRelThisFunc(a) \
1735 _LogRelItLikely(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1736#else
1737# define LogRelThisFunc(a) \
1738 do { LogRel(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRel(a); } while (0)
1739#endif
1740
1741/** @def LogRelMaxThisFunc
1742 * The same as LogRelFunc but for class functions (methods): the resulting log
1743 * line is additionally prepended with a hex value of |this| pointer.
1744 * @param a_cMax Max number of times this should hit the log.
1745 * @param a Log message in format <tt>("string\n" [, args])</tt>.
1746 */
1747#ifdef LOG_USE_C99
1748# define LogRelMaxThisFunc(a_cMax, a) \
1749 _LogRelMaxIt(a_cMax, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1750#else
1751# define LogRelMaxThisFunc(a_cMax, a) \
1752 do { LogRelMax(a_cMax, ("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelMax(a_cMax, a); } while (0)
1753#endif
1754
1755/** @def LogRelFlowThisFunc
1756 * The same as LogRelFlowFunc but for class functions (methods): the resulting
1757 * log line is additionally prepended with a hex value of |this| pointer.
1758 */
1759#ifdef LOG_USE_C99
1760# define LogRelFlowThisFunc(a) \
1761 _LogRelIt(RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__, _LogRemoveParentheseis a )
1762#else
1763# define LogRelFlowThisFunc(a) do { LogRelFlow(("{%p} " LOG_FN_FMT ": ", this, RT_GCC_EXTENSION __PRETTY_FUNCTION__)); LogRelFlow(a); } while (0)
1764#endif
1765
1766
1767/** Shortcut to |LogRelFlowFunc ("ENTER\n")|, marks the beginnig of the function. */
1768#define LogRelFlowFuncEnter() LogRelFlowFunc(("ENTER\n"))
1769
1770/** Shortcut to |LogRelFlowFunc ("LEAVE\n")|, marks the end of the function. */
1771#define LogRelFlowFuncLeave() LogRelFlowFunc(("LEAVE\n"))
1772
1773/** Shortcut to |LogRelFlowFunc ("LEAVE: %Rrc\n")|, marks the end of the function. */
1774#define LogRelFlowFuncLeaveRC(rc) LogRelFlowFunc(("LEAVE: %Rrc\n", (rc)))
1775
1776/** Shortcut to |LogRelFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */
1777#define LogRelFlowThisFuncEnter() LogRelFlowThisFunc(("ENTER\n"))
1778
1779/** Shortcut to |LogRelFlowThisFunc ("LEAVE\n")|, marks the end of the function. */
1780#define LogRelFlowThisFuncLeave() LogRelFlowThisFunc(("LEAVE\n"))
1781
1782/** @} */
1783
1784
1785/**
1786 * Sets the default release logger instance.
1787 *
1788 * @returns The old default instance.
1789 * @param pLogger The new default release logger instance.
1790 */
1791RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger);
1792
1793/**
1794 * Gets the default release logger instance.
1795 *
1796 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1797 */
1798RTDECL(PRTLOGGER) RTLogRelGetDefaultInstance(void);
1799
1800/**
1801 * Gets the default release logger instance.
1802 *
1803 * @returns Pointer to default release logger instance if availble, otherwise NULL.
1804 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1805 * the high 16 bits.
1806 */
1807RTDECL(PRTLOGGER) RTLogRelGetDefaultInstanceEx(uint32_t fFlagsAndGroup);
1808
1809/**
1810 * Write to a logger instance, defaulting to the release one.
1811 *
1812 * This function will check whether the instance, group and flags makes up a
1813 * logging kind which is currently enabled before writing anything to the log.
1814 *
1815 * @param pLogger Pointer to logger instance.
1816 * @param fFlags The logging flags.
1817 * @param iGroup The group.
1818 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1819 * only for internal usage!
1820 * @param pszFormat Format string.
1821 * @param ... Format arguments.
1822 * @remark This is a worker function for LogRelIt.
1823 */
1824RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
1825 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
1826
1827/**
1828 * Write to a logger instance, defaulting to the release one.
1829 *
1830 * This function will check whether the instance, group and flags makes up a
1831 * logging kind which is currently enabled before writing anything to the log.
1832 *
1833 * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
1834 * @param fFlags The logging flags.
1835 * @param iGroup The group.
1836 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
1837 * only for internal usage!
1838 * @param pszFormat Format string.
1839 * @param args Format arguments.
1840 */
1841RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
1842 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
1843
1844/**
1845 * printf like function for writing to the default release log.
1846 *
1847 * @param pszFormat Printf like format string.
1848 * @param ... Optional arguments as specified in pszFormat.
1849 *
1850 * @remark The API doesn't support formatting of floating point numbers at the moment.
1851 */
1852RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
1853
1854/**
1855 * vprintf like function for writing to the default release log.
1856 *
1857 * @param pszFormat Printf like format string.
1858 * @param args Optional arguments as specified in pszFormat.
1859 *
1860 * @remark The API doesn't support formatting of floating point numbers at the moment.
1861 */
1862RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
1863
1864/**
1865 * Changes the buffering setting of the default release logger.
1866 *
1867 * This can be used for optimizing longish logging sequences.
1868 *
1869 * @returns The old state.
1870 * @param fBuffered The new state.
1871 */
1872RTDECL(bool) RTLogRelSetBuffering(bool fBuffered);
1873
1874/** @} */
1875
1876
1877
1878/** @name COM port logging
1879 * @{
1880 */
1881
1882#ifdef DOXYGEN_RUNNING
1883# define LOG_TO_COM
1884# define LOG_NO_COM
1885#endif
1886
1887/** @def LOG_TO_COM
1888 * Redirects the normal logging macros to the serial versions.
1889 */
1890
1891/** @def LOG_NO_COM
1892 * Disables all LogCom* macros.
1893 */
1894
1895/** @def LogCom
1896 * Generic logging to serial port.
1897 */
1898#if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
1899# define LogCom(a) RTLogComPrintf a
1900#else
1901# define LogCom(a) do { } while (0)
1902#endif
1903
1904/** @def LogComFlow
1905 * Logging to serial port of execution flow.
1906 */
1907#if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
1908# define LogComFlow(a) RTLogComPrintf a
1909#else
1910# define LogComFlow(a) do { } while (0)
1911#endif
1912
1913#ifdef LOG_TO_COM
1914# undef Log
1915# define Log(a) LogCom(a)
1916# undef LogFlow
1917# define LogFlow(a) LogComFlow(a)
1918#endif
1919
1920/** @} */
1921
1922
1923/** @name Backdoor Logging
1924 * @{
1925 */
1926
1927#ifdef DOXYGEN_RUNNING
1928# define LOG_TO_BACKDOOR
1929# define LOG_NO_BACKDOOR
1930#endif
1931
1932/** @def LOG_TO_BACKDOOR
1933 * Redirects the normal logging macros to the backdoor versions.
1934 */
1935
1936/** @def LOG_NO_BACKDOOR
1937 * Disables all LogBackdoor* macros.
1938 */
1939
1940/** @def LogBackdoor
1941 * Generic logging to the VBox backdoor via port I/O.
1942 */
1943#if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1944# define LogBackdoor(a) RTLogBackdoorPrintf a
1945#else
1946# define LogBackdoor(a) do { } while (0)
1947#endif
1948
1949/** @def LogBackdoorFlow
1950 * Logging of execution flow messages to the backdoor I/O port.
1951 */
1952#if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
1953# define LogBackdoorFlow(a) RTLogBackdoorPrintf a
1954#else
1955# define LogBackdoorFlow(a) do { } while (0)
1956#endif
1957
1958/** @def LogRelBackdoor
1959 * Release logging to the VBox backdoor via port I/O.
1960 */
1961#if !defined(LOG_NO_BACKDOOR)
1962# define LogRelBackdoor(a) RTLogBackdoorPrintf a
1963#else
1964# define LogRelBackdoor(a) do { } while (0)
1965#endif
1966
1967#ifdef LOG_TO_BACKDOOR
1968# undef Log
1969# define Log(a) LogBackdoor(a)
1970# undef LogFlow
1971# define LogFlow(a) LogBackdoorFlow(a)
1972# undef LogRel
1973# define LogRel(a) LogRelBackdoor(a)
1974# if defined(LOG_USE_C99)
1975# undef _LogIt
1976# define _LogIt(a_fFlags, a_iGroup, ...) LogBackdoor((__VA_ARGS__))
1977# endif
1978#endif
1979
1980/** @} */
1981
1982
1983
1984/**
1985 * Gets the default logger instance, creating it if necessary.
1986 *
1987 * @returns Pointer to default logger instance if availble, otherwise NULL.
1988 */
1989RTDECL(PRTLOGGER) RTLogDefaultInstance(void);
1990
1991/**
1992 * Gets the logger instance if enabled, creating it if necessary.
1993 *
1994 * @returns Pointer to default logger instance, if group has the specified
1995 * flags enabled. Otherwise NULL is returned.
1996 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
1997 * the high 16 bits.
1998 */
1999RTDECL(PRTLOGGER) RTLogDefaultInstanceEx(uint32_t fFlagsAndGroup);
2000
2001/**
2002 * Gets the default logger instance (does not create one).
2003 *
2004 * @returns Pointer to default logger instance if availble, otherwise NULL.
2005 */
2006RTDECL(PRTLOGGER) RTLogGetDefaultInstance(void);
2007
2008/**
2009 * Gets the default logger instance if enabled (does not create one).
2010 *
2011 * @returns Pointer to default logger instance, if group has the specified
2012 * flags enabled. Otherwise NULL is returned.
2013 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
2014 * the high 16 bits.
2015 */
2016RTDECL(PRTLOGGER) RTLogGetDefaultInstanceEx(uint32_t fFlagsAndGroup);
2017
2018/**
2019 * Sets the default logger instance.
2020 *
2021 * @returns The old default instance.
2022 * @param pLogger The new default logger instance.
2023 */
2024RTDECL(PRTLOGGER) RTLogSetDefaultInstance(PRTLOGGER pLogger);
2025
2026#ifdef IN_RING0
2027/**
2028 * Changes the default logger instance for the current thread.
2029 *
2030 * @returns IPRT status code.
2031 * @param pLogger The logger instance. Pass NULL for deregistration.
2032 * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
2033 * all instances with this key will be deregistered. So in
2034 * order to only deregister the instance associated with the
2035 * current thread use 0.
2036 */
2037RTR0DECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
2038#endif /* IN_RING0 */
2039
2040/**
2041 * Creates the default logger instance for IPRT users.
2042 *
2043 * Any user of the logging features will need to implement
2044 * this or use the generic dummy.
2045 *
2046 * @returns Pointer to the logger instance.
2047 */
2048RTDECL(PRTLOGGER) RTLogDefaultInit(void);
2049
2050/**
2051 * This is the 2nd half of what RTLogGetDefaultInstanceEx() and
2052 * RTLogRelGetDefaultInstanceEx() does.
2053 *
2054 * @returns If the group has the specified flags enabled @a pLogger will be
2055 * returned returned. Otherwise NULL is returned.
2056 * @param pLogger The logger. NULL is NULL.
2057 * @param fFlagsAndGroup The flags in the lower 16 bits, the group number in
2058 * the high 16 bits.
2059 */
2060RTDECL(PRTLOGGER) RTLogCheckGroupFlags(PRTLOGGER pLogger, uint32_t fFlagsAndGroup);
2061
2062/**
2063 * Create a logger instance.
2064 *
2065 * @returns iprt status code.
2066 *
2067 * @param ppLogger Where to store the logger instance.
2068 * @param fFlags Logger instance flags, a combination of the
2069 * RTLOGFLAGS_* values.
2070 * @param pszGroupSettings The initial group settings.
2071 * @param pszEnvVarBase Base name for the environment variables for
2072 * this instance.
2073 * @param cGroups Number of groups in the array.
2074 * @param papszGroups Pointer to array of groups. This must stick
2075 * around for the life of the logger instance.
2076 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2077 * if pszFilenameFmt specified.
2078 * @param pszFilenameFmt Log filename format string. Standard
2079 * RTStrFormat().
2080 * @param ... Format arguments.
2081 */
2082RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, uint64_t fFlags, const char *pszGroupSettings,
2083 const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
2084 uint32_t fDestFlags, const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(8, 9);
2085
2086/**
2087 * Create a logger instance.
2088 *
2089 * @returns iprt status code.
2090 *
2091 * @param ppLogger Where to store the logger instance.
2092 * @param pszEnvVarBase Base name for the environment variables for
2093 * this instance (ring-3 only).
2094 * @param fFlags Logger instance flags, a combination of the
2095 * RTLOGFLAGS_* values.
2096 * @param pszGroupSettings The initial group settings.
2097 * @param cGroups Number of groups in the array.
2098 * @param papszGroups Pointer to array of groups. This must stick
2099 * around for the life of the logger instance.
2100 * @param cMaxEntriesPerGroup The max number of entries per group. UINT32_MAX
2101 * or zero for unlimited.
2102 * @param cBufDescs Number of buffer descriptors that @a paBufDescs
2103 * points to. Zero for defaults.
2104 * @param paBufDescs Buffer descriptors, optional.
2105 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2106 * if pszFilenameFmt specified.
2107 * @param pfnPhase Callback function for starting logging and for
2108 * ending or starting a new file for log history
2109 * rotation. NULL is OK.
2110 * @param cHistory Number of old log files to keep when performing
2111 * log history rotation. 0 means no history.
2112 * @param cbHistoryFileMax Maximum size of log file when performing
2113 * history rotation. 0 means no size limit.
2114 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2115 * performing history rotation, in seconds.
2116 * 0 means time limit.
2117 * @param pOutputIf The optional file output interface, can be NULL which will
2118 * make use of the default one.
2119 * @param pvOutputIfUser The opaque user data to pass to the callbacks in the output interface.
2120 * @param pErrInfo Where to return extended error information.
2121 * Optional.
2122 * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
2123 * @param ... Format arguments.
2124 */
2125RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, const char *pszEnvVarBase, uint64_t fFlags, const char *pszGroupSettings,
2126 unsigned cGroups, const char * const *papszGroups, uint32_t cMaxEntriesPerGroup,
2127 uint32_t cBufDescs, PRTLOGBUFFERDESC paBufDescs, uint32_t fDestFlags,
2128 PFNRTLOGPHASE pfnPhase, uint32_t cHistory, uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
2129 PCRTLOGOUTPUTIF pOutputIf, void *pvOutputIfUser,
2130 PRTERRINFO pErrInfo, const char *pszFilenameFmt, ...) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(18, 19);
2131
2132/**
2133 * Create a logger instance.
2134 *
2135 * @returns iprt status code.
2136 *
2137 * @param ppLogger Where to store the logger instance.
2138 * @param pszEnvVarBase Base name for the environment variables for
2139 * this instance (ring-3 only).
2140 * @param fFlags Logger instance flags, a combination of the
2141 * RTLOGFLAGS_* values.
2142 * @param pszGroupSettings The initial group settings.
2143 * @param cGroups Number of groups in the array.
2144 * @param papszGroups Pointer to array of groups. This must stick
2145 * around for the life of the logger instance.
2146 * @param cMaxEntriesPerGroup The max number of entries per group. UINT32_MAX
2147 * or zero for unlimited.
2148 * @param cBufDescs Number of buffer descriptors that @a paBufDescs
2149 * points to. Zero for defaults.
2150 * @param paBufDescs Buffer descriptors, optional.
2151 * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed
2152 * if pszFilenameFmt specified.
2153 * @param pfnPhase Callback function for starting logging and for
2154 * ending or starting a new file for log history
2155 * rotation.
2156 * @param cHistory Number of old log files to keep when performing
2157 * log history rotation. 0 means no history.
2158 * @param cbHistoryFileMax Maximum size of log file when performing
2159 * history rotation. 0 means no size limit.
2160 * @param cSecsHistoryTimeSlot Maximum time interval per log file when
2161 * performing history rotation, in seconds.
2162 * 0 means no time limit.
2163 * @param pOutputIf The optional file output interface, can be NULL which will
2164 * make use of the default one.
2165 * @param pvOutputIfUser The opaque user data to pass to the callbacks in the output interface.
2166 * @param pErrInfo Where to return extended error information.
2167 * Optional.
2168 * @param pszFilenameFmt Log filename format string. Standard
2169 * RTStrFormat().
2170 * @param va Format arguments.
2171 */
2172RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, const char *pszEnvVarBase, uint64_t fFlags, const char *pszGroupSettings,
2173 uint32_t cGroups, const char * const *papszGroups, uint32_t cMaxEntriesPerGroup,
2174 uint32_t cBufDescs, PRTLOGBUFFERDESC paBufDescs, uint32_t fDestFlags,
2175 PFNRTLOGPHASE pfnPhase, uint32_t cHistory, uint64_t cbHistoryFileMax, uint32_t cSecsHistoryTimeSlot,
2176 PCRTLOGOUTPUTIF pOutputIf, void *pvOutputIfUser,
2177 PRTERRINFO pErrInfo, const char *pszFilenameFmt, va_list va) RT_IPRT_FORMAT_ATTR_MAYBE_NULL(18, 0);
2178
2179/**
2180 * Destroys a logger instance.
2181 *
2182 * The instance is flushed and all output destinations closed (where applicable).
2183 *
2184 * @returns iprt status code.
2185 * @param pLogger The logger instance which close destroyed. NULL is fine.
2186 */
2187RTDECL(int) RTLogDestroy(PRTLOGGER pLogger);
2188
2189/**
2190 * Sets the custom prefix callback.
2191 *
2192 * @returns IPRT status code.
2193 * @param pLogger The logger instance.
2194 * @param pfnCallback The callback.
2195 * @param pvUser The user argument for the callback.
2196 * */
2197RTDECL(int) RTLogSetCustomPrefixCallback(PRTLOGGER pLogger, PFNRTLOGPREFIX pfnCallback, void *pvUser);
2198
2199/**
2200 * Sets the custom flush callback.
2201 *
2202 * This can be handy for special loggers like the per-EMT ones in ring-0,
2203 * but also for implementing a log viewer in the debugger GUI.
2204 *
2205 * @returns IPRT status code.
2206 * @retval VWRN_ALREADY_EXISTS if it was set to a different flusher.
2207 * @param pLogger The logger instance.
2208 * @param pfnFlush The flush callback.
2209 */
2210RTDECL(int) RTLogSetFlushCallback(PRTLOGGER pLogger, PFNRTLOGFLUSH pfnFlush);
2211
2212/**
2213 * Sets the thread name for a thread specific ring-0 logger.
2214 *
2215 * @returns IPRT status code.
2216 * @param pLogger The logger. NULL is not allowed.
2217 * @param pszNameFmt The format string for the thread name.
2218 * @param ... Format arguments.
2219 */
2220RTR0DECL(int) RTLogSetR0ThreadNameF(PRTLOGGER pLogger, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(2, 3);
2221
2222/**
2223 * Sets the thread name for a thread specific ring-0 logger.
2224 *
2225 * @returns IPRT status code.
2226 * @param pLogger The logger. NULL is not allowed.
2227 * @param pszNameFmt The format string for the thread name.
2228 * @param va Format arguments.
2229 */
2230RTR0DECL(int) RTLogSetR0ThreadNameV(PRTLOGGER pLogger, const char *pszNameFmt, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
2231
2232/**
2233 * Sets the program start time for a thread specific ring-0 logger.
2234 *
2235 * @returns IPRT status code.
2236 * @param pLogger The logger. NULL is not allowed.
2237 * @param nsStart The RTTimeNanoTS() value at program start.
2238 */
2239RTR0DECL(int) RTLogSetR0ProgramStart(PRTLOGGER pLogger, uint64_t nsStart);
2240
2241/**
2242 * Get the current log group settings as a string.
2243 *
2244 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2245 * @param pLogger Logger instance (NULL for default logger).
2246 * @param pszBuf The output buffer.
2247 * @param cchBuf The size of the output buffer. Must be greater than
2248 * zero.
2249 */
2250RTDECL(int) RTLogQueryGroupSettings(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
2251
2252/**
2253 * Updates the group settings for the logger instance using the specified
2254 * specification string.
2255 *
2256 * @returns iprt status code.
2257 * Failures can safely be ignored.
2258 * @param pLogger Logger instance (NULL for default logger).
2259 * @param pszValue Value to parse.
2260 */
2261RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger, const char *pszValue);
2262
2263/**
2264 * Sets the max number of entries per group.
2265 *
2266 * @returns Old restriction.
2267 *
2268 * @param pLogger The logger instance (NULL is an alias for the
2269 * default logger).
2270 * @param cMaxEntriesPerGroup The max number of entries per group.
2271 *
2272 * @remarks Lowering the limit of an active logger may quietly mute groups.
2273 * Raising it may reactive already muted groups.
2274 */
2275RTDECL(uint32_t) RTLogSetGroupLimit(PRTLOGGER pLogger, uint32_t cMaxEntriesPerGroup);
2276
2277/**
2278 * Gets the current flag settings for the given logger.
2279 *
2280 * @returns Logger flags, UINT64_MAX if no logger.
2281 * @param pLogger Logger instance (NULL for default logger).
2282 */
2283RTDECL(uint64_t) RTLogGetFlags(PRTLOGGER pLogger);
2284
2285/**
2286 * Modifies the flag settings for the given logger.
2287 *
2288 * @returns IPRT status code. Returns VINF_LOG_NO_LOGGER if no default logger
2289 * and @a pLogger is NULL.
2290 * @param pLogger Logger instance (NULL for default logger).
2291 * @param fSet Mask of flags to set (OR).
2292 * @param fClear Mask of flags to clear (NAND). This is allowed to
2293 * include invalid flags - e.g. UINT64_MAX is okay.
2294 */
2295RTDECL(int) RTLogChangeFlags(PRTLOGGER pLogger, uint64_t fSet, uint64_t fClear);
2296
2297/**
2298 * Updates the flags for the logger instance using the specified
2299 * specification string.
2300 *
2301 * @returns iprt status code.
2302 * Failures can safely be ignored.
2303 * @param pLogger Logger instance (NULL for default logger).
2304 * @param pszValue Value to parse.
2305 */
2306RTDECL(int) RTLogFlags(PRTLOGGER pLogger, const char *pszValue);
2307
2308/**
2309 * Changes the buffering setting of the specified logger.
2310 *
2311 * This can be used for optimizing longish logging sequences.
2312 *
2313 * @returns The old state.
2314 * @param pLogger The logger instance (NULL is an alias for the default
2315 * logger).
2316 * @param fBuffered The new state.
2317 */
2318RTDECL(bool) RTLogSetBuffering(PRTLOGGER pLogger, bool fBuffered);
2319
2320/**
2321 * Get the current log flags as a string.
2322 *
2323 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2324 * @param pLogger Logger instance (NULL for default logger).
2325 * @param pszBuf The output buffer.
2326 * @param cchBuf The size of the output buffer. Must be greater than
2327 * zero.
2328 */
2329RTDECL(int) RTLogQueryFlags(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
2330
2331/**
2332 * Gets the current destinations flags for the given logger.
2333 *
2334 * @returns Logger destination flags, UINT32_MAX if no logger.
2335 * @param pLogger Logger instance (NULL for default logger).
2336 */
2337RTDECL(uint32_t) RTLogGetDestinations(PRTLOGGER pLogger);
2338
2339/**
2340 * Modifies the log destinations settings for the given logger.
2341 *
2342 * This is only suitable for simple destination settings that doesn't take
2343 * additional arguments, like RTLOGDEST_FILE.
2344 *
2345 * @returns IPRT status code. Returns VINF_LOG_NO_LOGGER if no default logger
2346 * and @a pLogger is NULL.
2347 * @param pLogger Logger instance (NULL for default logger).
2348 * @param fSet Mask of destinations to set (OR).
2349 * @param fClear Mask of destinations to clear (NAND).
2350 */
2351RTDECL(int) RTLogChangeDestinations(PRTLOGGER pLogger, uint32_t fSet, uint32_t fClear);
2352
2353/**
2354 * Updates the logger destination using the specified string.
2355 *
2356 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2357 * @param pLogger Logger instance (NULL for default logger).
2358 * @param pszValue The value to parse.
2359 */
2360RTDECL(int) RTLogDestinations(PRTLOGGER pLogger, char const *pszValue);
2361
2362/**
2363 * Clear the file delay flag if set, opening the destination and flushing.
2364 *
2365 * @returns IPRT status code.
2366 * @param pLogger Logger instance (NULL for default logger).
2367 * @param pErrInfo Where to return extended error info. Optional.
2368 */
2369RTDECL(int) RTLogClearFileDelayFlag(PRTLOGGER pLogger, PRTERRINFO pErrInfo);
2370
2371/**
2372 * Get the current log destinations as a string.
2373 *
2374 * @returns VINF_SUCCESS or VERR_BUFFER_OVERFLOW.
2375 * @param pLogger Logger instance (NULL for default logger).
2376 * @param pszBuf The output buffer.
2377 * @param cchBuf The size of the output buffer. Must be greater than 0.
2378 */
2379RTDECL(int) RTLogQueryDestinations(PRTLOGGER pLogger, char *pszBuf, size_t cchBuf);
2380
2381/**
2382 * Performs a bulk update of logger flags and group flags.
2383 *
2384 * This is for instanced used for copying settings from ring-3 to ring-0
2385 * loggers.
2386 *
2387 * @returns IPRT status code.
2388 * @param pLogger The logger instance (NULL for default logger).
2389 * @param fFlags The new logger flags.
2390 * @param uGroupCrc32 The CRC32 of the group name strings.
2391 * @param cGroups Number of groups.
2392 * @param pafGroups Array of group flags.
2393 * @sa RTLogQueryBulk
2394 */
2395RTDECL(int) RTLogBulkUpdate(PRTLOGGER pLogger, uint64_t fFlags, uint32_t uGroupCrc32, uint32_t cGroups, uint32_t const *pafGroups);
2396
2397/**
2398 * Queries data for a bulk update of logger flags and group flags.
2399 *
2400 * This is for instanced used for copying settings from ring-3 to ring-0
2401 * loggers.
2402 *
2403 * @returns IPRT status code.
2404 * @retval VERR_BUFFER_OVERFLOW if pafGroups is too small, @a pcGroups will be
2405 * set to the actual number of groups.
2406 * @param pLogger The logger instance (NULL for default logger).
2407 * @param pfFlags Where to return the logger flags.
2408 * @param puGroupCrc32 Where to return the CRC32 of the group names.
2409 * @param pcGroups Input: Size of the @a pafGroups allocation.
2410 * Output: Actual number of groups returned.
2411 * @param pafGroups Where to return the flags for each group.
2412 * @sa RTLogBulkUpdate
2413 */
2414RTDECL(int) RTLogQueryBulk(PRTLOGGER pLogger, uint64_t *pfFlags, uint32_t *puGroupCrc32, uint32_t *pcGroups, uint32_t *pafGroups);
2415
2416/**
2417 * Write/copy bulk log data from another logger.
2418 *
2419 * This is used for transferring stuff from the ring-0 loggers and into the
2420 * ring-3 one. The text goes in as-is w/o any processing (i.e. prefixing or
2421 * newline fun).
2422 *
2423 * @returns IRPT status code.
2424 * @param pLogger The logger instance (NULL for default logger).
2425 * @param pszBefore Text to log before the bulk text. Optional.
2426 * @param pch Pointer to the block of bulk log text to write.
2427 * @param cch Size of the block of bulk log text to write.
2428 * @param pszAfter Text to log after the bulk text. Optional.
2429 */
2430RTDECL(int) RTLogBulkWrite(PRTLOGGER pLogger, const char *pszBefore, const char *pch, size_t cch, const char *pszAfter);
2431
2432/**
2433 * Flushes the specified logger.
2434 *
2435 * @returns IRPT status code.
2436 * @param pLogger The logger instance to flush.
2437 * If NULL the default instance is used. The default instance
2438 * will not be initialized by this call.
2439 */
2440RTDECL(int) RTLogFlush(PRTLOGGER pLogger);
2441
2442/**
2443 * Write to a logger instance.
2444 *
2445 * @param pLogger Pointer to logger instance.
2446 * @param pvCallerRet Ignored.
2447 * @param pszFormat Format string.
2448 * @param ... Format arguments.
2449 */
2450RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
2451
2452/**
2453 * Write to a logger instance.
2454 *
2455 * @param pLogger Pointer to logger instance.
2456 * @param pszFormat Format string.
2457 * @param args Format arguments.
2458 */
2459RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(2, 0);
2460
2461/**
2462 * Write to a logger instance.
2463 *
2464 * This function will check whether the instance, group and flags makes up a
2465 * logging kind which is currently enabled before writing anything to the log.
2466 *
2467 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2468 * @param fFlags The logging flags.
2469 * @param iGroup The group.
2470 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2471 * only for internal usage!
2472 * @param pszFormat Format string.
2473 * @param ... Format arguments.
2474 * @remark This is a worker function of LogIt.
2475 */
2476RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
2477 const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
2478
2479/**
2480 * Write to a logger instance.
2481 *
2482 * This function will check whether the instance, group and flags makes up a
2483 * logging kind which is currently enabled before writing anything to the log.
2484 *
2485 * @returns VINF_SUCCESS, VINF_LOG_NO_LOGGER, VINF_LOG_DISABLED, or IPRT error
2486 * status.
2487 * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
2488 * @param fFlags The logging flags.
2489 * @param iGroup The group.
2490 * The value ~0U is reserved for compatibility with RTLogLogger[V] and is
2491 * only for internal usage!
2492 * @param pszFormat Format string.
2493 * @param args Format arguments.
2494 */
2495RTDECL(int) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup,
2496 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
2497
2498/**
2499 * printf like function for writing to the default log.
2500 *
2501 * @param pszFormat Printf like format string.
2502 * @param ... Optional arguments as specified in pszFormat.
2503 *
2504 * @remark The API doesn't support formatting of floating point numbers at the moment.
2505 */
2506RTDECL(void) RTLogPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2507
2508/**
2509 * vprintf like function for writing to the default log.
2510 *
2511 * @param pszFormat Printf like format string.
2512 * @param va Optional arguments as specified in pszFormat.
2513 *
2514 * @remark The API doesn't support formatting of floating point numbers at the moment.
2515 */
2516RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
2517
2518/**
2519 * Dumper vprintf-like function outputting to a logger.
2520 *
2521 * @param pvUser Pointer to the logger instance to use, NULL for default
2522 * instance.
2523 * @param pszFormat Format string.
2524 * @param va Format arguments.
2525 */
2526RTDECL(void) RTLogDumpPrintfV(void *pvUser, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(2, 0);
2527
2528
2529#ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h & iprt/errcore.h */
2530#define DECLARED_FNRTSTROUTPUT
2531/**
2532 * Output callback.
2533 *
2534 * @returns number of bytes written.
2535 * @param pvArg User argument.
2536 * @param pachChars Pointer to an array of utf-8 characters.
2537 * @param cbChars Number of bytes in the character array pointed to by pachChars.
2538 */
2539typedef DECLCALLBACKTYPE(size_t, FNRTSTROUTPUT,(void *pvArg, const char *pachChars, size_t cbChars));
2540/** Pointer to callback function. */
2541typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
2542#endif
2543
2544/**
2545 * Partial vsprintf worker implementation.
2546 *
2547 * @returns number of bytes formatted.
2548 * @param pfnOutput Output worker.
2549 * Called in two ways. Normally with a string an it's length.
2550 * For termination, it's called with NULL for string, 0 for length.
2551 * @param pvArg Argument to output worker.
2552 * @param pszFormat Format string.
2553 * @param args Argument list.
2554 */
2555RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(3, 0);
2556
2557/**
2558 * Write log buffer to COM port.
2559 *
2560 * @param pach Pointer to the buffer to write.
2561 * @param cb Number of bytes to write.
2562 */
2563RTDECL(void) RTLogWriteCom(const char *pach, size_t cb);
2564
2565/**
2566 * Prints a formatted string to the serial port used for logging.
2567 *
2568 * @returns Number of bytes written.
2569 * @param pszFormat Format string.
2570 * @param ... Optional arguments specified in the format string.
2571 */
2572RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2573
2574/**
2575 * Prints a formatted string to the serial port used for logging.
2576 *
2577 * @returns Number of bytes written.
2578 * @param pszFormat Format string.
2579 * @param args Optional arguments specified in the format string.
2580 */
2581RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
2582
2583/**
2584 * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
2585 *
2586 * @param pach What to write.
2587 * @param cb How much to write.
2588 * @remark When linking statically, this function can be replaced by defining your own.
2589 */
2590RTDECL(void) RTLogWriteDebugger(const char *pach, size_t cb);
2591
2592/**
2593 * Write log buffer to a user defined output stream (RTLOGDEST_USER).
2594 *
2595 * @param pach What to write.
2596 * @param cb How much to write.
2597 * @remark When linking statically, this function can be replaced by defining your own.
2598 */
2599RTDECL(void) RTLogWriteUser(const char *pach, size_t cb);
2600
2601/**
2602 * Write log buffer to stdout (RTLOGDEST_STDOUT).
2603 *
2604 * @param pach What to write.
2605 * @param cb How much to write.
2606 * @remark When linking statically, this function can be replaced by defining your own.
2607 */
2608RTDECL(void) RTLogWriteStdOut(const char *pach, size_t cb);
2609
2610/**
2611 * Write log buffer to stdout (RTLOGDEST_STDERR).
2612 *
2613 * @param pach What to write.
2614 * @param cb How much to write.
2615 * @remark When linking statically, this function can be replaced by defining your own.
2616 */
2617RTDECL(void) RTLogWriteStdErr(const char *pach, size_t cb);
2618
2619#ifdef VBOX
2620
2621/**
2622 * Prints a formatted string to the backdoor port.
2623 *
2624 * @returns Number of bytes written.
2625 * @param pszFormat Format string.
2626 * @param ... Optional arguments specified in the format string.
2627 */
2628RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
2629
2630/**
2631 * Prints a formatted string to the backdoor port.
2632 *
2633 * @returns Number of bytes written.
2634 * @param pszFormat Format string.
2635 * @param args Optional arguments specified in the format string.
2636 */
2637RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(1, 0);
2638
2639#endif /* VBOX */
2640
2641RT_C_DECLS_END
2642
2643/** @} */
2644
2645#endif /* !IPRT_INCLUDED_log_h */
2646
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette