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