[1] | 1 | /** @file
|
---|
[2981] | 2 | * innotek Portable Runtime - Logging.
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[8155] | 6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[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.
|
---|
[8155] | 24 | *
|
---|
| 25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
| 26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
| 27 | * additional information or have any questions.
|
---|
[1] | 28 | */
|
---|
| 29 |
|
---|
[3630] | 30 | #ifndef ___iprt_log_h
|
---|
| 31 | #define ___iprt_log_h
|
---|
[1] | 32 |
|
---|
| 33 | #include <iprt/cdefs.h>
|
---|
| 34 | #include <iprt/types.h>
|
---|
| 35 | #include <iprt/stdarg.h>
|
---|
| 36 |
|
---|
| 37 | __BEGIN_DECLS
|
---|
| 38 |
|
---|
| 39 | /** @defgroup grp_rt_log RTLog - Logging
|
---|
| 40 | * @ingroup grp_rt
|
---|
| 41 | * @{
|
---|
| 42 | */
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
[2981] | 45 | * innotek Portable Runtime Logging Groups.
|
---|
[1] | 46 | * (Remember to update RT_LOGGROUP_NAMES!)
|
---|
| 47 | *
|
---|
| 48 | * @remark It should be pretty obvious, but just to have
|
---|
| 49 | * mentioned it, the values are sorted alphabetically (using the
|
---|
| 50 | * english alphabet) except for _DEFAULT which is always first.
|
---|
| 51 | *
|
---|
| 52 | * If anyone might be wondering what the alphabet looks like:
|
---|
| 53 | * a b c d e f g h i j k l m n o p q r s t u v w x y z
|
---|
| 54 | */
|
---|
| 55 | typedef enum RTLOGGROUP
|
---|
| 56 | {
|
---|
| 57 | /** Default logging group. */
|
---|
| 58 | RTLOGGROUP_DEFAULT,
|
---|
| 59 | RTLOGGROUP_DIR,
|
---|
| 60 | RTLOGGROUP_FILE,
|
---|
| 61 | RTLOGGROUP_FS,
|
---|
| 62 | RTLOGGROUP_LDR,
|
---|
| 63 | RTLOGGROUP_PATH,
|
---|
| 64 | RTLOGGROUP_PROCESS,
|
---|
| 65 | RTLOGGROUP_THREAD,
|
---|
| 66 | RTLOGGROUP_TIME,
|
---|
| 67 | RTLOGGROUP_TIMER,
|
---|
| 68 | RTLOGGROUP_ZIP = 31,
|
---|
| 69 | RTLOGGROUP_FIRST_USER = 32
|
---|
| 70 | } RTLOGGROUP;
|
---|
| 71 |
|
---|
| 72 | /** @def RT_LOGGROUP_NAMES
|
---|
[2981] | 73 | * innotek Portable Runtime Logging group names.
|
---|
[1] | 74 | *
|
---|
| 75 | * Must correspond 100% to RTLOGGROUP!
|
---|
| 76 | * Don't forget commas!
|
---|
| 77 | *
|
---|
| 78 | * @remark It should be pretty obvious, but just to have
|
---|
| 79 | * mentioned it, the values are sorted alphabetically (using the
|
---|
| 80 | * english alphabet) except for _DEFAULT which is always first.
|
---|
| 81 | *
|
---|
| 82 | * If anyone might be wondering what the alphabet looks like:
|
---|
| 83 | * a b c d e f g h i j k l m n o p q r s t u v w x y z
|
---|
| 84 | */
|
---|
| 85 | #define RT_LOGGROUP_NAMES \
|
---|
| 86 | "DEFAULT", \
|
---|
| 87 | "RT_DIR", \
|
---|
| 88 | "RT_FILE", \
|
---|
| 89 | "RT_FS", \
|
---|
| 90 | "RT_LDR", \
|
---|
| 91 | "RT_PATH", \
|
---|
| 92 | "RT_PROCESS", \
|
---|
[5511] | 93 | "RT_THREAD", \
|
---|
[1] | 94 | "RT_TIME", \
|
---|
| 95 | "RT_TIMER", \
|
---|
| 96 | "RT_10", \
|
---|
| 97 | "RT_11", \
|
---|
| 98 | "RT_12", \
|
---|
| 99 | "RT_13", \
|
---|
| 100 | "RT_14", \
|
---|
| 101 | "RT_15", \
|
---|
| 102 | "RT_16", \
|
---|
| 103 | "RT_17", \
|
---|
| 104 | "RT_18", \
|
---|
| 105 | "RT_19", \
|
---|
| 106 | "RT_20", \
|
---|
| 107 | "RT_21", \
|
---|
| 108 | "RT_22", \
|
---|
| 109 | "RT_23", \
|
---|
| 110 | "RT_24", \
|
---|
| 111 | "RT_25", \
|
---|
| 112 | "RT_26", \
|
---|
| 113 | "RT_27", \
|
---|
| 114 | "RT_28", \
|
---|
| 115 | "RT_29", \
|
---|
| 116 | "RT_30", \
|
---|
| 117 | "RT_ZIP" \
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | /** @def LOG_GROUP
|
---|
| 121 | * Active logging group.
|
---|
| 122 | */
|
---|
| 123 | #ifndef LOG_GROUP
|
---|
| 124 | # define LOG_GROUP RTLOGGROUP_DEFAULT
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 | /** @def LOG_INSTANCE
|
---|
| 128 | * Active logging instance.
|
---|
| 129 | */
|
---|
| 130 | #ifndef LOG_INSTANCE
|
---|
| 131 | # define LOG_INSTANCE NULL
|
---|
| 132 | #endif
|
---|
| 133 |
|
---|
| 134 | /** @def LOG_REL_INSTANCE
|
---|
| 135 | * Active release logging instance.
|
---|
| 136 | */
|
---|
| 137 | #ifndef LOG_REL_INSTANCE
|
---|
| 138 | # define LOG_REL_INSTANCE NULL
|
---|
| 139 | #endif
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | /** Logger structure. */
|
---|
| 143 | #ifdef IN_GC
|
---|
| 144 | typedef struct RTLOGGERGC RTLOGGER;
|
---|
| 145 | #else
|
---|
| 146 | typedef struct RTLOGGER RTLOGGER;
|
---|
| 147 | #endif
|
---|
| 148 | /** Pointer to logger structure. */
|
---|
| 149 | typedef RTLOGGER *PRTLOGGER;
|
---|
| 150 | /** Pointer to const logger structure. */
|
---|
| 151 | typedef const RTLOGGER *PCRTLOGGER;
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | /** Guest context logger structure. */
|
---|
| 155 | typedef struct RTLOGGERGC RTLOGGERGC;
|
---|
| 156 | /** Pointer to guest context logger structure. */
|
---|
| 157 | typedef RTLOGGERGC *PRTLOGGERGC;
|
---|
| 158 | /** Pointer to const guest context logger structure. */
|
---|
| 159 | typedef const RTLOGGERGC *PCRTLOGGERGC;
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 | /**
|
---|
| 163 | * Logger function.
|
---|
| 164 | *
|
---|
| 165 | * @param pszFormat Format string.
|
---|
| 166 | * @param ... Optional arguments as specified in the format string.
|
---|
| 167 | */
|
---|
| 168 | typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...);
|
---|
| 169 | /** Pointer to logger function. */
|
---|
| 170 | typedef FNRTLOGGER *PFNRTLOGGER;
|
---|
| 171 |
|
---|
| 172 | /**
|
---|
| 173 | * Flush function.
|
---|
| 174 | *
|
---|
| 175 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
| 176 | */
|
---|
| 177 | typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger);
|
---|
| 178 | /** Pointer to logger function. */
|
---|
| 179 | typedef FNRTLOGFLUSH *PFNRTLOGFLUSH;
|
---|
| 180 |
|
---|
| 181 | /**
|
---|
| 182 | * Flush function.
|
---|
| 183 | *
|
---|
| 184 | * @param pLogger Pointer to the logger instance which is to be flushed.
|
---|
| 185 | */
|
---|
| 186 | typedef DECLCALLBACK(void) FNRTLOGFLUSHGC(PRTLOGGERGC pLogger);
|
---|
| 187 | /** Pointer to logger function. */
|
---|
| 188 | typedef GCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC;
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | /**
|
---|
| 192 | * Logger instance structure for GC.
|
---|
| 193 | */
|
---|
| 194 | struct RTLOGGERGC
|
---|
| 195 | {
|
---|
| 196 | /** Pointer to temporary scratch buffer.
|
---|
| 197 | * This is used to format the log messages. */
|
---|
| 198 | char achScratch[16384];
|
---|
| 199 | /** Current scratch buffer position. */
|
---|
| 200 | RTUINT offScratch;
|
---|
| 201 | /** This is set if a prefix is pending. */
|
---|
| 202 | RTUINT fPendingPrefix;
|
---|
| 203 | /** Pointer to the logger function.
|
---|
| 204 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
| 205 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
| 206 | * A very unfortunate hack to work around the missing variadic macro support in C++. */
|
---|
| 207 | GCPTRTYPE(PFNRTLOGGER) pfnLogger;
|
---|
| 208 | /** Pointer to the flush function. */
|
---|
| 209 | PFNRTLOGFLUSHGC pfnFlush;
|
---|
| 210 | /** Magic number (RTLOGGERGC_MAGIC). */
|
---|
| 211 | uint32_t u32Magic;
|
---|
| 212 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
| 213 | RTUINT fFlags;
|
---|
| 214 | /** Number of groups in the afGroups member. */
|
---|
| 215 | RTUINT cGroups;
|
---|
| 216 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
| 217 | * This member have variable length and may extend way beyond
|
---|
| 218 | * the declared size of 1 entry. */
|
---|
| 219 | RTUINT afGroups[1];
|
---|
| 220 | };
|
---|
| 221 |
|
---|
| 222 | /** RTLOGGERGC::u32Magic value. (John Rogers Searle) */
|
---|
| 223 | #define RTLOGGERGC_MAGIC 0x19320731
|
---|
| 224 |
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | #ifndef IN_GC
|
---|
| 228 | /**
|
---|
| 229 | * Logger instance structure.
|
---|
| 230 | */
|
---|
| 231 | struct RTLOGGER
|
---|
| 232 | {
|
---|
| 233 | /** Pointer to temporary scratch buffer.
|
---|
| 234 | * This is used to format the log messages. */
|
---|
| 235 | char achScratch[16384];
|
---|
| 236 | /** Current scratch buffer position. */
|
---|
| 237 | RTUINT offScratch;
|
---|
| 238 | /** This is set if a prefix is pending. */
|
---|
| 239 | RTUINT fPendingPrefix;
|
---|
| 240 | /** Pointer to the logger function.
|
---|
| 241 | * This is actually pointer to a wrapper which will push a pointer to the
|
---|
| 242 | * instance pointer onto the stack before jumping to the real logger function.
|
---|
| 243 | * A very unfortunate hack to work around the missing variadic macro support in C++.
|
---|
| 244 | * (The memory is (not R0) allocated using RTMemExecAlloc().) */
|
---|
| 245 | PFNRTLOGGER pfnLogger;
|
---|
| 246 | /** Pointer to the flush function. */
|
---|
| 247 | PFNRTLOGFLUSH pfnFlush;
|
---|
| 248 | /** Mutex. */
|
---|
| 249 | RTSEMFASTMUTEX MutexSem;
|
---|
| 250 | /** Magic number. */
|
---|
| 251 | uint32_t u32Magic;
|
---|
| 252 | /** Logger instance flags - RTLOGFLAGS. */
|
---|
| 253 | RTUINT fFlags;
|
---|
| 254 | /** Destination flags - RTLOGDEST. */
|
---|
| 255 | RTUINT fDestFlags;
|
---|
| 256 | /** Handle to log file (if open). */
|
---|
| 257 | RTFILE File;
|
---|
| 258 | /** Pointer to filename.
|
---|
| 259 | * (The memory is allocated in the smae block as RTLOGGER.) */
|
---|
| 260 | char *pszFilename;
|
---|
| 261 | /** Pointer to the group name array.
|
---|
| 262 | * (The data is readonly and provided by the user.) */
|
---|
| 263 | const char * const *papszGroups;
|
---|
| 264 | /** The max number of groups that there is room for in afGroups and papszGroups.
|
---|
| 265 | * Used by RTLogCopyGroupAndFlags(). */
|
---|
| 266 | RTUINT cMaxGroups;
|
---|
| 267 | /** Number of groups in the afGroups and papszGroups members. */
|
---|
| 268 | RTUINT cGroups;
|
---|
| 269 | /** Group flags array - RTLOGGRPFLAGS.
|
---|
| 270 | * This member have variable length and may extend way beyond
|
---|
| 271 | * the declared size of 1 entry. */
|
---|
| 272 | RTUINT afGroups[1];
|
---|
| 273 | };
|
---|
| 274 |
|
---|
| 275 | /** RTLOGGER::u32Magic value. (Avram Noam Chomsky) */
|
---|
| 276 | #define RTLOGGER_MAGIC 0x19281207
|
---|
| 277 |
|
---|
| 278 | #endif
|
---|
| 279 |
|
---|
| 280 |
|
---|
| 281 | /**
|
---|
| 282 | * Logger flags.
|
---|
| 283 | */
|
---|
| 284 | typedef enum RTLOGFLAGS
|
---|
| 285 | {
|
---|
| 286 | /** The logger instance is disabled for normal output. */
|
---|
| 287 | RTLOGFLAGS_DISABLED = 0x00000001,
|
---|
| 288 | /** The logger instance is using buffered output. */
|
---|
| 289 | RTLOGFLAGS_BUFFERED = 0x00000002,
|
---|
[628] | 290 | /** The logger instance expands LF to CR/LF. */
|
---|
| 291 | RTLOGFLAGS_USECRLF = 0x00000010,
|
---|
[1] | 292 | /** Show relative timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
[7709] | 293 | RTLOGFLAGS_REL_TS = 0x00000020,
|
---|
[1] | 294 | /** Show decimal timestamps with PREFIX_TSC and PREFIX_TS */
|
---|
[7709] | 295 | RTLOGFLAGS_DECIMAL_TS = 0x00000040,
|
---|
| 296 | /** New lines should be reprefixed with the CPU id (ApicID on intel/amd). */
|
---|
| 297 | RTLOGFLAGS_PREFIX_CPUID = 0x00010000,
|
---|
[6515] | 298 | /** New lines should be prefixed with the native process id. */
|
---|
| 299 | RTLOGFLAGS_PREFIX_PID = 0x00020000,
|
---|
[1] | 300 | /** New lines should be prefixed with group flag number causing the output. */
|
---|
| 301 | RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000,
|
---|
| 302 | /** New lines should be prefixed with group flag name causing the output. */
|
---|
| 303 | RTLOGFLAGS_PREFIX_FLAG = 0x00080000,
|
---|
| 304 | /** New lines should be prefixed with group number. */
|
---|
| 305 | RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000,
|
---|
| 306 | /** New lines should be prefixed with group name. */
|
---|
| 307 | RTLOGFLAGS_PREFIX_GROUP = 0x00200000,
|
---|
| 308 | /** New lines should be prefixed with the native thread id. */
|
---|
| 309 | RTLOGFLAGS_PREFIX_TID = 0x00400000,
|
---|
| 310 | /** New lines should be prefixed with thread name. */
|
---|
| 311 | RTLOGFLAGS_PREFIX_THREAD = 0x00800000,
|
---|
| 312 | /** New lines should be prefixed with formatted timestamp since program start. */
|
---|
| 313 | RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000,
|
---|
| 314 | /** New lines should be prefixed with formatted timestamp (UCT). */
|
---|
| 315 | RTLOGFLAGS_PREFIX_TIME = 0x08000000,
|
---|
| 316 | /** New lines should be prefixed with milliseconds since program start. */
|
---|
| 317 | RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000,
|
---|
| 318 | /** New lines should be prefixed with timestamp. */
|
---|
| 319 | RTLOGFLAGS_PREFIX_TSC = 0x20000000,
|
---|
| 320 | /** New lines should be prefixed with timestamp. */
|
---|
| 321 | RTLOGFLAGS_PREFIX_TS = 0x40000000,
|
---|
| 322 | /** The prefix mask. */
|
---|
| 323 | RTLOGFLAGS_PREFIX_MASK = 0x7cff0000
|
---|
| 324 | } RTLOGFLAGS;
|
---|
| 325 |
|
---|
| 326 | /**
|
---|
| 327 | * Logger per group flags.
|
---|
| 328 | */
|
---|
| 329 | typedef enum RTLOGGRPFLAGS
|
---|
| 330 | {
|
---|
| 331 | /** Enabled. */
|
---|
| 332 | RTLOGGRPFLAGS_ENABLED = 0x00000001,
|
---|
| 333 | /** Level 1 logging. */
|
---|
| 334 | RTLOGGRPFLAGS_LEVEL_1 = 0x00000002,
|
---|
| 335 | /** Level 2 logging. */
|
---|
| 336 | RTLOGGRPFLAGS_LEVEL_2 = 0x00000004,
|
---|
| 337 | /** Level 3 logging. */
|
---|
| 338 | RTLOGGRPFLAGS_LEVEL_3 = 0x00000008,
|
---|
| 339 | /** Level 4 logging. */
|
---|
| 340 | RTLOGGRPFLAGS_LEVEL_4 = 0x00000010,
|
---|
| 341 | /** Level 5 logging. */
|
---|
| 342 | RTLOGGRPFLAGS_LEVEL_5 = 0x00000020,
|
---|
| 343 | /** Level 6 logging. */
|
---|
| 344 | RTLOGGRPFLAGS_LEVEL_6 = 0x00000040,
|
---|
| 345 | /** Flow logging. */
|
---|
| 346 | RTLOGGRPFLAGS_FLOW = 0x00000080,
|
---|
| 347 |
|
---|
| 348 | /** Lelik logging. */
|
---|
| 349 | RTLOGGRPFLAGS_LELIK = 0x00000100,
|
---|
| 350 | /** Michael logging. */
|
---|
| 351 | RTLOGGRPFLAGS_MICHAEL = 0x00000200,
|
---|
| 352 | /** dmik logging. */
|
---|
| 353 | RTLOGGRPFLAGS_DMIK = 0x00000400,
|
---|
| 354 | /** sunlover logging. */
|
---|
| 355 | RTLOGGRPFLAGS_SUNLOVER = 0x00000800,
|
---|
| 356 | /** Achim logging. */
|
---|
| 357 | RTLOGGRPFLAGS_ACHIM = 0x00001000,
|
---|
| 358 | /** Sander logging. */
|
---|
| 359 | RTLOGGRPFLAGS_SANDER = 0x00002000,
|
---|
| 360 | /** Klaus logging. */
|
---|
| 361 | RTLOGGRPFLAGS_KLAUS = 0x00004000,
|
---|
| 362 | /** Frank logging. */
|
---|
| 363 | RTLOGGRPFLAGS_FRANK = 0x00008000,
|
---|
| 364 | /** bird logging. */
|
---|
| 365 | RTLOGGRPFLAGS_BIRD = 0x00010000,
|
---|
| 366 | /** NoName logging. */
|
---|
| 367 | RTLOGGRPFLAGS_NONAME = 0x00020000
|
---|
| 368 | } RTLOGGRPFLAGS;
|
---|
| 369 |
|
---|
| 370 | /**
|
---|
| 371 | * Logger destination type.
|
---|
| 372 | */
|
---|
| 373 | typedef enum RTLOGDEST
|
---|
| 374 | {
|
---|
| 375 | /** Log to file. */
|
---|
| 376 | RTLOGDEST_FILE = 0x00000001,
|
---|
| 377 | /** Log to stdout. */
|
---|
| 378 | RTLOGDEST_STDOUT = 0x00000002,
|
---|
| 379 | /** Log to stderr. */
|
---|
| 380 | RTLOGDEST_STDERR = 0x00000004,
|
---|
| 381 | /** Log to debugger (win32 only). */
|
---|
| 382 | RTLOGDEST_DEBUGGER = 0x00000008,
|
---|
| 383 | /** Log to com port. */
|
---|
| 384 | RTLOGDEST_COM = 0x00000010,
|
---|
| 385 | /** Just a dummy flag to be used when no other flag applies. */
|
---|
| 386 | RTLOGDEST_DUMMY = 0x20000000,
|
---|
| 387 | /** Log to a user defined output stream. */
|
---|
| 388 | RTLOGDEST_USER = 0x40000000
|
---|
| 389 | } RTLOGDEST;
|
---|
| 390 |
|
---|
| 391 |
|
---|
| 392 | RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
| 393 |
|
---|
| 394 |
|
---|
| 395 | /*
|
---|
| 396 | * Determin whether logging is enabled and forcefully normalize the indicators.
|
---|
| 397 | */
|
---|
| 398 | #if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED)
|
---|
| 399 | # undef LOG_DISABLED
|
---|
| 400 | # undef LOG_ENABLED
|
---|
| 401 | # define LOG_ENABLED
|
---|
| 402 | #else
|
---|
| 403 | # undef LOG_ENABLED
|
---|
| 404 | # undef LOG_DISABLED
|
---|
| 405 | # define LOG_DISABLED
|
---|
| 406 | #endif
|
---|
| 407 |
|
---|
| 408 |
|
---|
| 409 | /** @def LogIt
|
---|
| 410 | * Write to specific logger if group enabled.
|
---|
| 411 | */
|
---|
| 412 | #ifdef LOG_ENABLED
|
---|
[7602] | 413 | # if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
|
---|
| 414 | # define _LogRemoveParentheseis(...) __VA_ARGS__
|
---|
| 415 | # define _LogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
|
---|
| 416 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) _LogIt(pvInst, fFlags, iGroup, _LogRemoveParentheseis fmtargs)
|
---|
| 417 | # else
|
---|
| 418 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
[1] | 419 | do \
|
---|
| 420 | { \
|
---|
| 421 | register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \
|
---|
| 422 | if (LogIt_pLogger) \
|
---|
| 423 | { \
|
---|
| 424 | register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
|
---|
| 425 | if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
| 426 | LogIt_pLogger->pfnLogger fmtargs; \
|
---|
| 427 | } \
|
---|
| 428 | } while (0)
|
---|
[7602] | 429 | # endif
|
---|
[1] | 430 | #else
|
---|
| 431 | # define LogIt(pvInst, fFlags, iGroup, fmtargs) do { } while (0)
|
---|
| 432 | #endif
|
---|
| 433 |
|
---|
| 434 |
|
---|
| 435 | /** @def Log
|
---|
| 436 | * Level 1 logging.
|
---|
| 437 | */
|
---|
| 438 | #define Log(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
| 439 |
|
---|
| 440 | /** @def Log2
|
---|
| 441 | * Level 2 logging.
|
---|
| 442 | */
|
---|
| 443 | #define Log2(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
| 444 |
|
---|
| 445 | /** @def Log3
|
---|
| 446 | * Level 3 logging.
|
---|
| 447 | */
|
---|
| 448 | #define Log3(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
| 449 |
|
---|
| 450 | /** @def Log4
|
---|
| 451 | * Level 4 logging.
|
---|
| 452 | */
|
---|
| 453 | #define Log4(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
| 454 |
|
---|
| 455 | /** @def Log5
|
---|
| 456 | * Level 5 logging.
|
---|
| 457 | */
|
---|
| 458 | #define Log5(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
| 459 |
|
---|
| 460 | /** @def Log6
|
---|
| 461 | * Level 6 logging.
|
---|
| 462 | */
|
---|
| 463 | #define Log6(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
| 464 |
|
---|
| 465 | /** @def LogFlow
|
---|
| 466 | * Logging of execution flow.
|
---|
| 467 | */
|
---|
| 468 | #define LogFlow(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
| 469 |
|
---|
| 470 | /** @def LogLelik
|
---|
| 471 | * lelik logging.
|
---|
| 472 | */
|
---|
| 473 | #define LogLelik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 | /** @def LogMichael
|
---|
| 477 | * michael logging.
|
---|
| 478 | */
|
---|
| 479 | #define LogMichael(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
| 480 |
|
---|
| 481 | /** @def LogDmik
|
---|
| 482 | * dmik logging.
|
---|
| 483 | */
|
---|
| 484 | #define LogDmik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_DMIK, LOG_GROUP, a)
|
---|
| 485 |
|
---|
| 486 | /** @def LogSunlover
|
---|
| 487 | * sunlover logging.
|
---|
| 488 | */
|
---|
| 489 | #define LogSunlover(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
| 490 |
|
---|
| 491 | /** @def LogAchim
|
---|
| 492 | * Achim logging.
|
---|
| 493 | */
|
---|
| 494 | #define LogAchim(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
| 495 |
|
---|
| 496 | /** @def LogSander
|
---|
| 497 | * Sander logging.
|
---|
| 498 | */
|
---|
| 499 | #define LogSander(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
| 500 |
|
---|
| 501 | /** @def LogKlaus
|
---|
| 502 | * klaus logging.
|
---|
| 503 | */
|
---|
| 504 | #define LogKlaus(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
| 505 |
|
---|
| 506 | /** @def LogFrank
|
---|
| 507 | * frank logging.
|
---|
| 508 | */
|
---|
| 509 | #define LogFrank(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
| 510 |
|
---|
| 511 | /** @def LogBird
|
---|
| 512 | * bird logging.
|
---|
| 513 | */
|
---|
| 514 | #define LogBird(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
| 515 |
|
---|
| 516 | /** @def LogNoName
|
---|
| 517 | * NoName logging.
|
---|
| 518 | */
|
---|
| 519 | #define LogNoName(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
| 520 |
|
---|
| 521 |
|
---|
| 522 | /** @def LogWarning
|
---|
| 523 | * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message.
|
---|
| 524 | * @param m custom log message in format <tt>("string\n" [, args])</tt>
|
---|
| 525 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 526 | * join two separate Log* calls and make this op atomic
|
---|
| 527 | */
|
---|
| 528 | #define LogWarning(m) \
|
---|
| 529 | do { Log(("WARNING! ")); Log(m); } while (0)
|
---|
| 530 |
|
---|
| 531 | /** @def LogTrace
|
---|
| 532 | * Macro to trace the execution flow: logs the file name, line number and
|
---|
| 533 | * function name. Can be easily searched for in log files using the
|
---|
| 534 | * ">>>>>" pattern (prepended to the beginning of each line).
|
---|
| 535 | */
|
---|
| 536 | #define LogTrace() \
|
---|
| 537 | LogFlow((">>>>> %s (%d): %s\n", __FILE__, __LINE__, __PRETTY_FUNCTION__))
|
---|
| 538 |
|
---|
| 539 | /** @def LogTraceMsg
|
---|
| 540 | * The same as LogTrace but logs a custom log message right after the trace line.
|
---|
| 541 | * @param m custom log message in format <tt>("string\n" [, args])</tt>
|
---|
| 542 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 543 | * join two separate Log* calls and make this op atomic
|
---|
| 544 | */
|
---|
| 545 | #define LogTraceMsg(m) \
|
---|
| 546 | do { LogTrace(); LogFlow(m); } while (0)
|
---|
| 547 |
|
---|
[4860] | 548 | /** @def LogFunc
|
---|
| 549 | * Level 1 logging inside C/C++ functions.
|
---|
| 550 | * Prepends the given log message with the function name followed by a semicolon
|
---|
| 551 | * and space.
|
---|
| 552 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 553 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 554 | * join two separate Log* calls and make this op atomic
|
---|
| 555 | */
|
---|
| 556 | #define LogFunc(m) \
|
---|
| 557 | do { Log(("%s: ", __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
| 558 |
|
---|
| 559 | /** @def LogThisFunc
|
---|
| 560 | * The same as LogFunc but for class functions (methods): the resulting log
|
---|
| 561 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
| 562 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 563 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 564 | * join two separate Log* calls and make this op atomic
|
---|
| 565 | */
|
---|
| 566 | #define LogThisFunc(m) \
|
---|
| 567 | do { Log(("{%p} %s: ", this, __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
| 568 |
|
---|
[1] | 569 | /** @def LogFlowFunc
|
---|
| 570 | * Macro to log the execution flow inside C/C++ functions.
|
---|
| 571 | * Prepends the given log message with the function name followed by a semicolon
|
---|
| 572 | * and space.
|
---|
| 573 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 574 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 575 | * join two separate Log* calls and make this op atomic
|
---|
| 576 | */
|
---|
| 577 | #define LogFlowFunc(m) \
|
---|
| 578 | do { LogFlow(("%s: ", __PRETTY_FUNCTION__)); LogFlow(m); } while (0)
|
---|
| 579 |
|
---|
| 580 | /** @def LogWarningFunc
|
---|
| 581 | * The same as LogWarning(), but prepents the log message with the function name.
|
---|
| 582 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 583 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 584 | * join two separate Log* calls and make this op atomic
|
---|
| 585 | */
|
---|
| 586 | #define LogWarningFunc(m) \
|
---|
| 587 | do { Log(("%s: WARNING! ", __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
| 588 |
|
---|
| 589 | /** @def LogFlowThisFunc
|
---|
| 590 | * The same as LogFlowFunc but for class functions (methods): the resulting log
|
---|
| 591 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
| 592 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 593 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 594 | * join two separate Log* calls and make this op atomic
|
---|
| 595 | */
|
---|
| 596 | #define LogFlowThisFunc(m) \
|
---|
| 597 | do { LogFlow(("{%p} %s: ", this, __PRETTY_FUNCTION__)); LogFlow(m); } while (0)
|
---|
| 598 |
|
---|
| 599 | /** @def LogWarningThisFunc
|
---|
| 600 | * The same as LogWarningFunc() but for class functions (methods): the resulting
|
---|
| 601 | * log line is additionally perpended with a hex value of |this| pointer.
|
---|
| 602 | * @param m log message in format <tt>("string\n" [, args])</tt>
|
---|
| 603 | * @todo use a Log macro with a variable argument list (requires MSVC8) to
|
---|
| 604 | * join two separate Log* calls and make this op atomic
|
---|
| 605 | */
|
---|
| 606 | #define LogWarningThisFunc(m) \
|
---|
| 607 | do { Log(("{%p} %s: WARNING! ", this, __PRETTY_FUNCTION__)); Log(m); } while (0)
|
---|
| 608 |
|
---|
| 609 | /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function */
|
---|
| 610 | #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n"))
|
---|
| 611 |
|
---|
| 612 | /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function */
|
---|
| 613 | #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n"))
|
---|
| 614 |
|
---|
| 615 | /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function */
|
---|
| 616 | #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n"))
|
---|
| 617 |
|
---|
| 618 | /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function */
|
---|
| 619 | #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n"))
|
---|
| 620 |
|
---|
| 621 | /** @def LogObjRefCnt
|
---|
| 622 | * Helper macro to print the current reference count of the given COM object
|
---|
| 623 | * to the log file.
|
---|
| 624 | * @param obj object in question (must be a pointer to an IUnknown subclass
|
---|
| 625 | * or simply define COM-style AddRef() and Release() methods)
|
---|
| 626 | * @note Use it only for temporary debugging. It leaves dummy code even if
|
---|
| 627 | * logging is disabled.
|
---|
| 628 | */
|
---|
| 629 | #define LogObjRefCnt(obj) \
|
---|
| 630 | do { \
|
---|
| 631 | int refc = (obj)->AddRef(); -- refc; \
|
---|
| 632 | LogFlow((#obj "{%p}.refCnt=%d\n", (obj), refc)); \
|
---|
| 633 | (obj)->Release(); \
|
---|
| 634 | } while (0)
|
---|
| 635 |
|
---|
| 636 |
|
---|
| 637 | /** @def LogIsItEnabled
|
---|
| 638 | * Checks whether the specified logging group is enabled or not.
|
---|
| 639 | */
|
---|
| 640 | #ifdef LOG_ENABLED
|
---|
| 641 | # define LogIsItEnabled(pvInst, fFlags, iGroup) \
|
---|
| 642 | LogIsItEnabledInternal((pvInst), (unsigned)(iGroup), (unsigned)(fFlags))
|
---|
| 643 | #else
|
---|
| 644 | # define LogIsItEnabled(pvInst, fFlags, iGroup) (false)
|
---|
| 645 | #endif
|
---|
| 646 |
|
---|
| 647 | /** @def LogIsEnabled
|
---|
| 648 | * Checks whether level 1 logging is enabled.
|
---|
| 649 | */
|
---|
| 650 | #define LogIsEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
| 651 |
|
---|
| 652 | /** @def LogIs2Enabled
|
---|
| 653 | * Checks whether level 2 logging is enabled.
|
---|
| 654 | */
|
---|
| 655 | #define LogIs2Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
| 656 |
|
---|
| 657 | /** @def LogIs3Enabled
|
---|
| 658 | * Checks whether level 3 logging is enabled.
|
---|
| 659 | */
|
---|
| 660 | #define LogIs3Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
| 661 |
|
---|
| 662 | /** @def LogIs4Enabled
|
---|
| 663 | * Checks whether level 4 logging is enabled.
|
---|
| 664 | */
|
---|
| 665 | #define LogIs4Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
| 666 |
|
---|
| 667 | /** @def LogIs5Enabled
|
---|
| 668 | * Checks whether level 5 logging is enabled.
|
---|
| 669 | */
|
---|
| 670 | #define LogIs5Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
| 671 |
|
---|
| 672 | /** @def LogIs6Enabled
|
---|
| 673 | * Checks whether level 6 logging is enabled.
|
---|
| 674 | */
|
---|
| 675 | #define LogIs6Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
| 676 |
|
---|
| 677 | /** @def LogIsFlowEnabled
|
---|
| 678 | * Checks whether execution flow logging is enabled.
|
---|
| 679 | */
|
---|
| 680 | #define LogIsFlowEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
| 681 |
|
---|
| 682 |
|
---|
[7170] | 683 | #ifdef DOXYGEN_RUNNING
|
---|
[1] | 684 | # define LOG_DISABLED
|
---|
| 685 | # define LOG_ENABLED
|
---|
| 686 | # define LOG_ENABLE_FLOW
|
---|
| 687 | #endif
|
---|
| 688 |
|
---|
| 689 | /** @def LOG_DISABLED
|
---|
| 690 | * Use this compile time define to disable all logging macros. It can
|
---|
| 691 | * be overriden for each of the logging macros by the LOG_ENABLE*
|
---|
| 692 | * compile time defines.
|
---|
| 693 | */
|
---|
| 694 |
|
---|
| 695 | /** @def LOG_ENABLED
|
---|
| 696 | * Use this compile time define to enable logging when not in debug mode
|
---|
| 697 | * or LOG_DISABLED is set.
|
---|
| 698 | * This will enabled Log() only.
|
---|
| 699 | */
|
---|
| 700 |
|
---|
| 701 | /** @def LOG_ENABLE_FLOW
|
---|
| 702 | * Use this compile time define to enable flow logging when not in
|
---|
| 703 | * debug mode or LOG_DISABLED is defined.
|
---|
| 704 | * This will enable LogFlow() only.
|
---|
| 705 | */
|
---|
| 706 |
|
---|
| 707 |
|
---|
| 708 |
|
---|
| 709 | /** @name Release Logging
|
---|
| 710 | * @{
|
---|
| 711 | */
|
---|
| 712 |
|
---|
| 713 | /** @def LogIt
|
---|
| 714 | * Write to specific logger if group enabled.
|
---|
| 715 | */
|
---|
[7602] | 716 | #if defined(RT_ARCH_AMD64) || defined(LOG_USE_C99)
|
---|
| 717 | # define _LogRelRemoveParentheseis(...) __VA_ARGS__
|
---|
| 718 | # define _LogRelIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__)
|
---|
| 719 | # define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
[1] | 720 | do \
|
---|
| 721 | { \
|
---|
| 722 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \
|
---|
| 723 | if (LogRelIt_pLogger) \
|
---|
[529] | 724 | _LogRelIt(LogRelIt_pLogger, fFlags, iGroup, _LogRelRemoveParentheseis fmtargs); \
|
---|
[1] | 725 | LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \
|
---|
| 726 | } while (0)
|
---|
[7602] | 727 | #else
|
---|
| 728 | # define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \
|
---|
[1] | 729 | do \
|
---|
| 730 | { \
|
---|
| 731 | PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \
|
---|
| 732 | if (LogRelIt_pLogger) \
|
---|
| 733 | { \
|
---|
| 734 | unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \
|
---|
| 735 | if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \
|
---|
| 736 | LogRelIt_pLogger->pfnLogger fmtargs; \
|
---|
| 737 | } \
|
---|
| 738 | LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \
|
---|
| 739 | } while (0)
|
---|
[7602] | 740 | #endif
|
---|
[1] | 741 |
|
---|
| 742 |
|
---|
| 743 | /** @def LogRel
|
---|
| 744 | * Level 1 logging.
|
---|
| 745 | */
|
---|
| 746 | #define LogRel(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a)
|
---|
| 747 |
|
---|
| 748 | /** @def LogRel2
|
---|
| 749 | * Level 2 logging.
|
---|
| 750 | */
|
---|
| 751 | #define LogRel2(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a)
|
---|
| 752 |
|
---|
| 753 | /** @def LogRel3
|
---|
| 754 | * Level 3 logging.
|
---|
| 755 | */
|
---|
| 756 | #define LogRel3(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a)
|
---|
| 757 |
|
---|
| 758 | /** @def LogRel4
|
---|
| 759 | * Level 4 logging.
|
---|
| 760 | */
|
---|
| 761 | #define LogRel4(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a)
|
---|
| 762 |
|
---|
| 763 | /** @def LogRel5
|
---|
| 764 | * Level 5 logging.
|
---|
| 765 | */
|
---|
| 766 | #define LogRel5(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a)
|
---|
| 767 |
|
---|
| 768 | /** @def LogRel6
|
---|
| 769 | * Level 6 logging.
|
---|
| 770 | */
|
---|
| 771 | #define LogRel6(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a)
|
---|
| 772 |
|
---|
| 773 | /** @def LogRelFlow
|
---|
| 774 | * Logging of execution flow.
|
---|
| 775 | */
|
---|
| 776 | #define LogRelFlow(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a)
|
---|
| 777 |
|
---|
[4351] | 778 | /** @def LogRelFunc
|
---|
| 779 | * Release logging. Prepends the given log message with the function name
|
---|
| 780 | * followed by a semicolon and space.
|
---|
| 781 | */
|
---|
| 782 | #define LogRelFunc(a) \
|
---|
| 783 | do { LogRel(("%s: ", __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
| 784 |
|
---|
| 785 | /** @def LogRelThisFunc
|
---|
| 786 | * The same as LogRelFunc but for class functions (methods): the resulting log
|
---|
| 787 | * line is additionally perpended with a hex value of |this| pointer.
|
---|
| 788 | */
|
---|
| 789 | #define LogRelThisFunc(a) \
|
---|
| 790 | do { LogRel(("{%p} %s: ", this, __PRETTY_FUNCTION__)); LogRel(a); } while (0)
|
---|
| 791 |
|
---|
[1] | 792 | /** @def LogRelLelik
|
---|
| 793 | * lelik logging.
|
---|
| 794 | */
|
---|
| 795 | #define LogRelLelik(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a)
|
---|
| 796 |
|
---|
| 797 | /** @def LogRelMichael
|
---|
| 798 | * michael logging.
|
---|
| 799 | */
|
---|
| 800 | #define LogRelMichael(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a)
|
---|
| 801 |
|
---|
| 802 | /** @def LogRelDmik
|
---|
| 803 | * dmik logging.
|
---|
| 804 | */
|
---|
| 805 | #define LogRelDmik(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_DMIK, LOG_GROUP, a)
|
---|
| 806 |
|
---|
| 807 | /** @def LogRelSunlover
|
---|
| 808 | * sunlover logging.
|
---|
| 809 | */
|
---|
| 810 | #define LogRelSunlover(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a)
|
---|
| 811 |
|
---|
| 812 | /** @def LogRelAchim
|
---|
| 813 | * Achim logging.
|
---|
| 814 | */
|
---|
| 815 | #define LogRelAchim(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a)
|
---|
| 816 |
|
---|
| 817 | /** @def LogRelSander
|
---|
| 818 | * Sander logging.
|
---|
| 819 | */
|
---|
| 820 | #define LogRelSander(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a)
|
---|
| 821 |
|
---|
| 822 | /** @def LogRelKlaus
|
---|
| 823 | * klaus logging.
|
---|
| 824 | */
|
---|
| 825 | #define LogRelKlaus(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a)
|
---|
| 826 |
|
---|
| 827 | /** @def LogRelFrank
|
---|
| 828 | * frank logging.
|
---|
| 829 | */
|
---|
| 830 | #define LogRelFrank(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a)
|
---|
| 831 |
|
---|
| 832 | /** @def LogRelBird
|
---|
| 833 | * bird logging.
|
---|
| 834 | */
|
---|
| 835 | #define LogRelBird(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a)
|
---|
| 836 |
|
---|
| 837 | /** @def LogRelNoName
|
---|
| 838 | * NoName logging.
|
---|
| 839 | */
|
---|
| 840 | #define LogRelNoName(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a)
|
---|
| 841 |
|
---|
| 842 |
|
---|
| 843 | /** @def LogRelIsItEnabled
|
---|
| 844 | * Checks whether the specified logging group is enabled or not.
|
---|
| 845 | */
|
---|
| 846 | #define LogRelIsItEnabled(pvInst, fFlags, iGroup) \
|
---|
| 847 | LogRelIsItEnabledInternal((pvInst), (unsigned)(iGroup), (unsigned)(fFlags))
|
---|
| 848 |
|
---|
| 849 | /** @def LogRelIsEnabled
|
---|
| 850 | * Checks whether level 1 logging is enabled.
|
---|
| 851 | */
|
---|
| 852 | #define LogRelIsEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP)
|
---|
| 853 |
|
---|
| 854 | /** @def LogRelIs2Enabled
|
---|
| 855 | * Checks whether level 2 logging is enabled.
|
---|
| 856 | */
|
---|
| 857 | #define LogRelIs2Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP)
|
---|
| 858 |
|
---|
| 859 | /** @def LogRelIs3Enabled
|
---|
| 860 | * Checks whether level 3 logging is enabled.
|
---|
| 861 | */
|
---|
| 862 | #define LogRelIs3Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP)
|
---|
| 863 |
|
---|
| 864 | /** @def LogRelIs4Enabled
|
---|
| 865 | * Checks whether level 4 logging is enabled.
|
---|
| 866 | */
|
---|
| 867 | #define LogRelIs4Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP)
|
---|
| 868 |
|
---|
| 869 | /** @def LogRelIs5Enabled
|
---|
| 870 | * Checks whether level 5 logging is enabled.
|
---|
| 871 | */
|
---|
| 872 | #define LogRelIs5Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP)
|
---|
| 873 |
|
---|
| 874 | /** @def LogRelIs6Enabled
|
---|
| 875 | * Checks whether level 6 logging is enabled.
|
---|
| 876 | */
|
---|
| 877 | #define LogRelIs6Enabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP)
|
---|
| 878 |
|
---|
| 879 | /** @def LogRelIsFlowEnabled
|
---|
| 880 | * Checks whether execution flow logging is enabled.
|
---|
| 881 | */
|
---|
| 882 | #define LogRelIsFlowEnabled() LogRelIsItEnabled(LOG_REL_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP)
|
---|
| 883 |
|
---|
| 884 |
|
---|
| 885 | #ifndef IN_GC
|
---|
| 886 | /**
|
---|
| 887 | * Sets the default release logger instance.
|
---|
| 888 | *
|
---|
| 889 | * @returns The old default instance.
|
---|
| 890 | * @param pLogger The new default release logger instance.
|
---|
| 891 | */
|
---|
| 892 | RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger);
|
---|
| 893 | #endif /* !IN_GC */
|
---|
| 894 |
|
---|
| 895 | /**
|
---|
| 896 | * Gets the default release logger instance.
|
---|
| 897 | *
|
---|
| 898 | * @returns Pointer to default release logger instance.
|
---|
| 899 | * @returns NULL if no default release logger instance available.
|
---|
| 900 | */
|
---|
| 901 | RTDECL(PRTLOGGER) RTLogRelDefaultInstance(void);
|
---|
| 902 |
|
---|
| 903 | /** Internal worker function.
|
---|
| 904 | * Don't call directly, use the LogRelIsItEnabled macro!
|
---|
| 905 | */
|
---|
| 906 | DECLINLINE(bool) LogRelIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
| 907 | {
|
---|
| 908 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogRelDefaultInstance();
|
---|
| 909 | if (pLogger)
|
---|
| 910 | {
|
---|
| 911 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
| 912 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
| 913 | return true;
|
---|
| 914 | }
|
---|
| 915 | return false;
|
---|
| 916 | }
|
---|
| 917 |
|
---|
| 918 | /**
|
---|
| 919 | * Write to a logger instance, defaulting to the release one.
|
---|
| 920 | *
|
---|
| 921 | * This function will check whether the instance, group and flags makes up a
|
---|
| 922 | * logging kind which is currently enabled before writing anything to the log.
|
---|
| 923 | *
|
---|
| 924 | * @param pLogger Pointer to logger instance.
|
---|
| 925 | * @param fFlags The logging flags.
|
---|
| 926 | * @param iGroup The group.
|
---|
| 927 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
| 928 | * only for internal usage!
|
---|
| 929 | * @param pszFormat Format string.
|
---|
| 930 | * @param ... Format arguments.
|
---|
| 931 | * @remark This is a worker function for LogRelIt.
|
---|
| 932 | */
|
---|
| 933 | RTDECL(void) RTLogRelLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
| 934 |
|
---|
| 935 | /**
|
---|
| 936 | * Write to a logger instance, defaulting to the release one.
|
---|
| 937 | *
|
---|
| 938 | * This function will check whether the instance, group and flags makes up a
|
---|
| 939 | * logging kind which is currently enabled before writing anything to the log.
|
---|
| 940 | *
|
---|
| 941 | * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
|
---|
| 942 | * @param fFlags The logging flags.
|
---|
| 943 | * @param iGroup The group.
|
---|
| 944 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
| 945 | * only for internal usage!
|
---|
| 946 | * @param pszFormat Format string.
|
---|
| 947 | * @param args Format arguments.
|
---|
| 948 | */
|
---|
| 949 | RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
| 950 |
|
---|
| 951 | /**
|
---|
| 952 | * printf like function for writing to the default release log.
|
---|
| 953 | *
|
---|
| 954 | * @param pszFormat Printf like format string.
|
---|
| 955 | * @param ... Optional arguments as specified in pszFormat.
|
---|
| 956 | *
|
---|
| 957 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
| 958 | */
|
---|
| 959 | RTDECL(void) RTLogRelPrintf(const char *pszFormat, ...);
|
---|
| 960 |
|
---|
| 961 | /**
|
---|
| 962 | * vprintf like function for writing to the default release log.
|
---|
| 963 | *
|
---|
| 964 | * @param pszFormat Printf like format string.
|
---|
| 965 | * @param args Optional arguments as specified in pszFormat.
|
---|
| 966 | *
|
---|
| 967 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
| 968 | */
|
---|
| 969 | RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args);
|
---|
| 970 |
|
---|
[3242] | 971 |
|
---|
[1] | 972 | /** @} */
|
---|
| 973 |
|
---|
| 974 |
|
---|
[3242] | 975 |
|
---|
| 976 | /** @name COM port logging
|
---|
| 977 | * {
|
---|
| 978 | */
|
---|
| 979 |
|
---|
[7170] | 980 | #ifdef DOXYGEN_RUNNING
|
---|
[3242] | 981 | # define LOG_TO_COM
|
---|
| 982 | # define LOG_NO_COM
|
---|
| 983 | #endif
|
---|
| 984 |
|
---|
| 985 | /** @def LOG_TO_COM
|
---|
| 986 | * Redirects the normal loging macros to the serial versions.
|
---|
| 987 | */
|
---|
| 988 |
|
---|
| 989 | /** @def LOG_NO_COM
|
---|
| 990 | * Disables all LogCom* macros.
|
---|
| 991 | */
|
---|
| 992 |
|
---|
| 993 | /** @def LogCom
|
---|
| 994 | * Generic logging to serial port.
|
---|
| 995 | */
|
---|
| 996 | #if defined(LOG_ENABLED) && !defined(LOG_NO_COM)
|
---|
| 997 | # define LogCom(a) RTLogComPrintf a
|
---|
| 998 | #else
|
---|
| 999 | # define LogCom(a) do { } while (0)
|
---|
| 1000 | #endif
|
---|
| 1001 |
|
---|
| 1002 | /** @def LogComFlow
|
---|
| 1003 | * Logging to serial port of execution flow.
|
---|
| 1004 | */
|
---|
| 1005 | #if defined(LOG_ENABLED) && defined(LOG_ENABLE_FLOW) && !defined(LOG_NO_COM)
|
---|
| 1006 | # define LogComFlow(a) RTLogComPrintf a
|
---|
| 1007 | #else
|
---|
| 1008 | # define LogComFlow(a) do { } while (0)
|
---|
| 1009 | #endif
|
---|
| 1010 |
|
---|
| 1011 | #ifdef LOG_TO_COM
|
---|
| 1012 | # undef Log
|
---|
| 1013 | # define Log(a) LogCom(a)
|
---|
| 1014 | # undef LogFlow
|
---|
| 1015 | # define LogFlow(a) LogComFlow(a)
|
---|
| 1016 | #endif
|
---|
| 1017 |
|
---|
| 1018 | /** @} */
|
---|
| 1019 |
|
---|
| 1020 |
|
---|
| 1021 | /** @name Backdoor Logging
|
---|
| 1022 | * @{
|
---|
| 1023 | */
|
---|
| 1024 |
|
---|
[7170] | 1025 | #ifdef DOXYGEN_RUNNING
|
---|
[3242] | 1026 | # define LOG_TO_BACKDOOR
|
---|
| 1027 | # define LOG_NO_BACKDOOR
|
---|
| 1028 | #endif
|
---|
| 1029 |
|
---|
| 1030 | /** @def LOG_TO_BACKDOOR
|
---|
| 1031 | * Redirects the normal logging macros to the backdoor versions.
|
---|
| 1032 | */
|
---|
| 1033 |
|
---|
| 1034 | /** @def LOG_NO_BACKDOOR
|
---|
| 1035 | * Disables all LogBackdoor* macros.
|
---|
| 1036 | */
|
---|
| 1037 |
|
---|
| 1038 | /** @def LogBackdoor
|
---|
| 1039 | * Generic logging to the VBox backdoor via port I/O.
|
---|
| 1040 | */
|
---|
| 1041 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
| 1042 | # define LogBackdoor(a) RTLogBackdoorPrintf a
|
---|
| 1043 | #else
|
---|
| 1044 | # define LogBackdoor(a) do { } while (0)
|
---|
| 1045 | #endif
|
---|
| 1046 |
|
---|
| 1047 | /** @def LogBackdoorFlow
|
---|
| 1048 | * Logging of execution flow messages to the backdoor I/O port.
|
---|
| 1049 | */
|
---|
| 1050 | #if defined(LOG_ENABLED) && !defined(LOG_NO_BACKDOOR)
|
---|
| 1051 | # define LogBackdoorFlow(a) RTLogBackdoorPrintf a
|
---|
| 1052 | #else
|
---|
| 1053 | # define LogBackdoorFlow(a) do { } while (0)
|
---|
| 1054 | #endif
|
---|
| 1055 |
|
---|
| 1056 | /** @def LogRelBackdoor
|
---|
[3243] | 1057 | * Release logging to the VBox backdoor via port I/O.
|
---|
[3242] | 1058 | */
|
---|
| 1059 | #if !defined(LOG_NO_BACKDOOR)
|
---|
| 1060 | # define LogRelBackdoor(a) RTLogBackdoorPrintf a
|
---|
| 1061 | #else
|
---|
| 1062 | # define LogRelBackdoor(a) do { } while (0)
|
---|
| 1063 | #endif
|
---|
| 1064 |
|
---|
| 1065 | #ifdef LOG_TO_BACKDOOR
|
---|
| 1066 | # undef Log
|
---|
| 1067 | # define Log(a) LogBackdoor(a)
|
---|
| 1068 | # undef LogFlow
|
---|
| 1069 | # define LogFlow(a) LogBackdoorFlow(a)
|
---|
| 1070 | # undef LogRel
|
---|
| 1071 | # define LogRel(a) LogRelBackdoor(a)
|
---|
| 1072 | #endif
|
---|
| 1073 |
|
---|
| 1074 | /** @} */
|
---|
| 1075 |
|
---|
| 1076 |
|
---|
| 1077 |
|
---|
| 1078 |
|
---|
[1] | 1079 | /**
|
---|
| 1080 | * Gets the default logger instance.
|
---|
| 1081 | *
|
---|
| 1082 | * @returns Pointer to default logger instance.
|
---|
| 1083 | * @returns NULL if no default logger instance available.
|
---|
| 1084 | */
|
---|
| 1085 | RTDECL(PRTLOGGER) RTLogDefaultInstance(void);
|
---|
| 1086 |
|
---|
| 1087 | #ifdef IN_RING0
|
---|
| 1088 | /**
|
---|
| 1089 | * Changes the default logger instance for the current thread.
|
---|
| 1090 | *
|
---|
| 1091 | * @returns IPRT status code.
|
---|
| 1092 | * @param pLogger The logger instance. Pass NULL for deregistration.
|
---|
| 1093 | * @param uKey Associated key for cleanup purposes. If pLogger is NULL,
|
---|
| 1094 | * all instances with this key will be deregistered. So in
|
---|
| 1095 | * order to only deregister the instance associated with the
|
---|
| 1096 | * current thread use 0.
|
---|
| 1097 | */
|
---|
| 1098 | RTDECL(int) RTLogSetDefaultInstanceThread(PRTLOGGER pLogger, uintptr_t uKey);
|
---|
| 1099 | #endif /* IN_RING0 */
|
---|
| 1100 |
|
---|
| 1101 |
|
---|
| 1102 | #ifdef LOG_ENABLED
|
---|
| 1103 | /** Internal worker function.
|
---|
| 1104 | * Don't call directly, use the LogIsItEnabled macro!
|
---|
| 1105 | */
|
---|
| 1106 | DECLINLINE(bool) LogIsItEnabledInternal(void *pvInst, unsigned iGroup, unsigned fFlags)
|
---|
| 1107 | {
|
---|
| 1108 | register PRTLOGGER pLogger = (PRTLOGGER)pvInst ? (PRTLOGGER)pvInst : RTLogDefaultInstance();
|
---|
| 1109 | if (pLogger)
|
---|
| 1110 | {
|
---|
| 1111 | register unsigned fGrpFlags = pLogger->afGroups[(unsigned)iGroup < pLogger->cGroups ? (unsigned)iGroup : 0];
|
---|
| 1112 | if ((fGrpFlags & (fFlags | RTLOGGRPFLAGS_ENABLED)) == (fFlags | RTLOGGRPFLAGS_ENABLED))
|
---|
| 1113 | return true;
|
---|
| 1114 | }
|
---|
| 1115 | return false;
|
---|
| 1116 | }
|
---|
| 1117 | #endif
|
---|
| 1118 |
|
---|
| 1119 |
|
---|
| 1120 | #ifndef IN_GC
|
---|
| 1121 | /**
|
---|
| 1122 | * Creates the default logger instance for a iprt users.
|
---|
| 1123 | *
|
---|
| 1124 | * Any user of the logging features will need to implement
|
---|
| 1125 | * this or use the generic dummy.
|
---|
| 1126 | *
|
---|
| 1127 | * @returns Pointer to the logger instance.
|
---|
| 1128 | */
|
---|
| 1129 | RTDECL(PRTLOGGER) RTLogDefaultInit(void);
|
---|
| 1130 |
|
---|
| 1131 | /**
|
---|
| 1132 | * Create a logger instance.
|
---|
| 1133 | *
|
---|
| 1134 | * @returns iprt status code.
|
---|
| 1135 | *
|
---|
| 1136 | * @param ppLogger Where to store the logger instance.
|
---|
| 1137 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
| 1138 | * @param pszGroupSettings The initial group settings.
|
---|
| 1139 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
| 1140 | * @param cGroups Number of groups in the array.
|
---|
| 1141 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
| 1142 | * logger instance.
|
---|
| 1143 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
| 1144 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
| 1145 | * @param ... Format arguments.
|
---|
| 1146 | */
|
---|
| 1147 | RTDECL(int) RTLogCreate(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
| 1148 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
| 1149 | RTUINT fDestFlags, const char *pszFilenameFmt, ...);
|
---|
| 1150 |
|
---|
| 1151 | /**
|
---|
[3086] | 1152 | * Create a logger instance.
|
---|
| 1153 | *
|
---|
| 1154 | * @returns iprt status code.
|
---|
| 1155 | *
|
---|
| 1156 | * @param ppLogger Where to store the logger instance.
|
---|
| 1157 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
| 1158 | * @param pszGroupSettings The initial group settings.
|
---|
| 1159 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
| 1160 | * @param cGroups Number of groups in the array.
|
---|
| 1161 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
| 1162 | * logger instance.
|
---|
| 1163 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
| 1164 | * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
|
---|
| 1165 | * @param cchErrorMsg The size of the error message buffer.
|
---|
| 1166 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
| 1167 | * @param ... Format arguments.
|
---|
| 1168 | */
|
---|
| 1169 | RTDECL(int) RTLogCreateEx(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
| 1170 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
| 1171 | RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, ...);
|
---|
| 1172 |
|
---|
| 1173 | /**
|
---|
| 1174 | * Create a logger instance.
|
---|
| 1175 | *
|
---|
| 1176 | * @returns iprt status code.
|
---|
| 1177 | *
|
---|
| 1178 | * @param ppLogger Where to store the logger instance.
|
---|
| 1179 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
| 1180 | * @param pszGroupSettings The initial group settings.
|
---|
| 1181 | * @param pszEnvVarBase Base name for the environment variables for this instance.
|
---|
| 1182 | * @param cGroups Number of groups in the array.
|
---|
| 1183 | * @param papszGroups Pointer to array of groups. This must stick around for the life of the
|
---|
| 1184 | * logger instance.
|
---|
| 1185 | * @param fDestFlags The destination flags. RTLOGDEST_FILE is ORed if pszFilenameFmt specified.
|
---|
| 1186 | * @param pszErrorMsg A buffer which is filled with an error message if something fails. May be NULL.
|
---|
| 1187 | * @param cchErrorMsg The size of the error message buffer.
|
---|
| 1188 | * @param pszFilenameFmt Log filename format string. Standard RTStrFormat().
|
---|
| 1189 | * @param args Format arguments.
|
---|
| 1190 | */
|
---|
| 1191 | RTDECL(int) RTLogCreateExV(PRTLOGGER *ppLogger, RTUINT fFlags, const char *pszGroupSettings,
|
---|
| 1192 | const char *pszEnvVarBase, unsigned cGroups, const char * const * papszGroups,
|
---|
| 1193 | RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args);
|
---|
| 1194 |
|
---|
| 1195 | /**
|
---|
[1] | 1196 | * Create a logger instance for singled threaded ring-0 usage.
|
---|
| 1197 | *
|
---|
| 1198 | * @returns iprt status code.
|
---|
| 1199 | *
|
---|
| 1200 | * @param pLogger Where to create the logger instance.
|
---|
| 1201 | * @param cbLogger The amount of memory available for the logger instance.
|
---|
| 1202 | * @param pfnLogger Pointer to logger wrapper function for the clone.
|
---|
| 1203 | * @param pfnFlush Pointer to flush function for the clone.
|
---|
| 1204 | * @param fFlags Logger instance flags for the clone, a combination of the RTLOGFLAGS_* values.
|
---|
| 1205 | * @param fDestFlags The destination flags.
|
---|
| 1206 | */
|
---|
| 1207 | RTDECL(int) RTLogCreateForR0(PRTLOGGER pLogger, size_t cbLogger, PFNRTLOGGER pfnLogger, PFNRTLOGFLUSH pfnFlush, RTUINT fFlags, RTUINT fDestFlags);
|
---|
| 1208 |
|
---|
| 1209 | /**
|
---|
| 1210 | * Destroys a logger instance.
|
---|
| 1211 | *
|
---|
| 1212 | * The instance is flushed and all output destinations closed (where applicable).
|
---|
| 1213 | *
|
---|
| 1214 | * @returns iprt status code.
|
---|
| 1215 | * @param pLogger The logger instance which close destroyed.
|
---|
| 1216 | */
|
---|
| 1217 | RTDECL(int) RTLogDestroy(PRTLOGGER pLogger);
|
---|
| 1218 |
|
---|
| 1219 | /**
|
---|
| 1220 | * Create a logger instance clone for GC usage.
|
---|
| 1221 | *
|
---|
| 1222 | * @returns iprt status code.
|
---|
| 1223 | *
|
---|
| 1224 | * @param pLogger The logger instance to be cloned.
|
---|
| 1225 | * @param pLoggerGC Where to create the GC logger instance.
|
---|
| 1226 | * @param cbLoggerGC Amount of memory allocated to for the GC logger instance clone.
|
---|
| 1227 | * @param pfnLoggerGCPtr Pointer to logger wrapper function for this instance (GC Ptr).
|
---|
| 1228 | * @param pfnFlushGCPtr Pointer to flush function (GC Ptr).
|
---|
| 1229 | * @param fFlags Logger instance flags, a combination of the RTLOGFLAGS_* values.
|
---|
| 1230 | */
|
---|
| 1231 | RTDECL(int) RTLogCloneGC(PRTLOGGER pLogger, PRTLOGGERGC pLoggerGC, size_t cbLoggerGC,
|
---|
| 1232 | RTGCPTR pfnLoggerGCPtr, RTGCPTR pfnFlushGCPtr, RTUINT fFlags);
|
---|
| 1233 |
|
---|
| 1234 | /**
|
---|
| 1235 | * Flushes a GC logger instance to a HC logger.
|
---|
| 1236 | *
|
---|
| 1237 | * @returns iprt status code.
|
---|
| 1238 | * @param pLogger The HC logger instance to flush pLoggerGC to.
|
---|
| 1239 | * If NULL the default logger is used.
|
---|
| 1240 | * @param pLoggerGC The GC logger instance to flush.
|
---|
| 1241 | */
|
---|
| 1242 | RTDECL(void) RTLogFlushGC(PRTLOGGER pLogger, PRTLOGGERGC pLoggerGC);
|
---|
| 1243 |
|
---|
| 1244 | /**
|
---|
| 1245 | * Flushes the buffer in one logger instance onto another logger.
|
---|
| 1246 | *
|
---|
| 1247 | * @returns iprt status code.
|
---|
| 1248 | *
|
---|
| 1249 | * @param pSrcLogger The logger instance to flush.
|
---|
| 1250 | * @param pDstLogger The logger instance to flush onto.
|
---|
| 1251 | * If NULL the default logger will be used.
|
---|
| 1252 | */
|
---|
| 1253 | RTDECL(void) RTLogFlushToLogger(PRTLOGGER pSrcLogger, PRTLOGGER pDstLogger);
|
---|
| 1254 |
|
---|
| 1255 | /**
|
---|
| 1256 | * Copies the group settings and flags from logger instance to another.
|
---|
| 1257 | *
|
---|
| 1258 | * @returns IPRT status code.
|
---|
| 1259 | * @param pDstLogger The destination logger instance.
|
---|
| 1260 | * @param pSrcLogger The source logger instance. If NULL the default one is used.
|
---|
| 1261 | * @param fFlagsOr OR mask for the flags.
|
---|
| 1262 | * @param fFlagsAnd AND mask for the flags.
|
---|
| 1263 | */
|
---|
| 1264 | RTDECL(int) RTLogCopyGroupsAndFlags(PRTLOGGER pDstLogger, PCRTLOGGER pSrcLogger, unsigned fFlagsOr, unsigned fFlagsAnd);
|
---|
| 1265 |
|
---|
| 1266 | /**
|
---|
| 1267 | * Updates the group settings for the logger instance using the specified
|
---|
| 1268 | * specification string.
|
---|
| 1269 | *
|
---|
| 1270 | * @returns iprt status code.
|
---|
| 1271 | * Failures can safely be ignored.
|
---|
| 1272 | * @param pLogger Logger instance (NULL for default logger).
|
---|
| 1273 | * @param pszVar Value to parse.
|
---|
| 1274 | */
|
---|
| 1275 | RTDECL(int) RTLogGroupSettings(PRTLOGGER pLogger, const char *pszVar);
|
---|
| 1276 | #endif /* !IN_GC */
|
---|
| 1277 |
|
---|
| 1278 | /**
|
---|
| 1279 | * Updates the flags for the logger instance using the specified
|
---|
| 1280 | * specification string.
|
---|
| 1281 | *
|
---|
| 1282 | * @returns iprt status code.
|
---|
| 1283 | * Failures can safely be ignored.
|
---|
| 1284 | * @param pLogger Logger instance (NULL for default logger).
|
---|
| 1285 | * @param pszVar Value to parse.
|
---|
| 1286 | */
|
---|
| 1287 | RTDECL(int) RTLogFlags(PRTLOGGER pLogger, const char *pszVar);
|
---|
| 1288 |
|
---|
| 1289 | /**
|
---|
| 1290 | * Flushes the specified logger.
|
---|
| 1291 | *
|
---|
| 1292 | * @param pLogger The logger instance to flush.
|
---|
| 1293 | * If NULL the default instance is used. The default instance
|
---|
| 1294 | * will not be initialized by this call.
|
---|
| 1295 | */
|
---|
| 1296 | RTDECL(void) RTLogFlush(PRTLOGGER pLogger);
|
---|
| 1297 |
|
---|
| 1298 | /**
|
---|
| 1299 | * Write to a logger instance.
|
---|
| 1300 | *
|
---|
| 1301 | * @param pLogger Pointer to logger instance.
|
---|
| 1302 | * @param pvCallerRet Ignored.
|
---|
| 1303 | * @param pszFormat Format string.
|
---|
| 1304 | * @param ... Format arguments.
|
---|
| 1305 | */
|
---|
| 1306 | RTDECL(void) RTLogLogger(PRTLOGGER pLogger, void *pvCallerRet, const char *pszFormat, ...);
|
---|
| 1307 |
|
---|
| 1308 | /**
|
---|
| 1309 | * Write to a logger instance.
|
---|
| 1310 | *
|
---|
| 1311 | * @param pLogger Pointer to logger instance.
|
---|
| 1312 | * @param pszFormat Format string.
|
---|
| 1313 | * @param args Format arguments.
|
---|
| 1314 | */
|
---|
| 1315 | RTDECL(void) RTLogLoggerV(PRTLOGGER pLogger, const char *pszFormat, va_list args);
|
---|
| 1316 |
|
---|
| 1317 | /**
|
---|
| 1318 | * Write to a logger instance.
|
---|
| 1319 | *
|
---|
| 1320 | * This function will check whether the instance, group and flags makes up a
|
---|
| 1321 | * logging kind which is currently enabled before writing anything to the log.
|
---|
| 1322 | *
|
---|
| 1323 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
| 1324 | * @param fFlags The logging flags.
|
---|
| 1325 | * @param iGroup The group.
|
---|
| 1326 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
| 1327 | * only for internal usage!
|
---|
| 1328 | * @param pszFormat Format string.
|
---|
| 1329 | * @param ... Format arguments.
|
---|
| 1330 | * @remark This is a worker function of LogIt.
|
---|
| 1331 | */
|
---|
| 1332 | RTDECL(void) RTLogLoggerEx(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...);
|
---|
| 1333 |
|
---|
| 1334 | /**
|
---|
| 1335 | * Write to a logger instance.
|
---|
| 1336 | *
|
---|
| 1337 | * This function will check whether the instance, group and flags makes up a
|
---|
| 1338 | * logging kind which is currently enabled before writing anything to the log.
|
---|
| 1339 | *
|
---|
| 1340 | * @param pLogger Pointer to logger instance. If NULL the default logger instance will be attempted.
|
---|
| 1341 | * @param fFlags The logging flags.
|
---|
| 1342 | * @param iGroup The group.
|
---|
| 1343 | * The value ~0U is reserved for compatability with RTLogLogger[V] and is
|
---|
| 1344 | * only for internal usage!
|
---|
| 1345 | * @param pszFormat Format string.
|
---|
| 1346 | * @param args Format arguments.
|
---|
| 1347 | */
|
---|
| 1348 | RTDECL(void) RTLogLoggerExV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args);
|
---|
| 1349 |
|
---|
| 1350 | /**
|
---|
| 1351 | * printf like function for writing to the default log.
|
---|
| 1352 | *
|
---|
| 1353 | * @param pszFormat Printf like format string.
|
---|
| 1354 | * @param ... Optional arguments as specified in pszFormat.
|
---|
| 1355 | *
|
---|
| 1356 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
| 1357 | */
|
---|
| 1358 | RTDECL(void) RTLogPrintf(const char *pszFormat, ...);
|
---|
| 1359 |
|
---|
| 1360 | /**
|
---|
| 1361 | * vprintf like function for writing to the default log.
|
---|
| 1362 | *
|
---|
| 1363 | * @param pszFormat Printf like format string.
|
---|
| 1364 | * @param args Optional arguments as specified in pszFormat.
|
---|
| 1365 | *
|
---|
| 1366 | * @remark The API doesn't support formatting of floating point numbers at the moment.
|
---|
| 1367 | */
|
---|
| 1368 | RTDECL(void) RTLogPrintfV(const char *pszFormat, va_list args);
|
---|
| 1369 |
|
---|
| 1370 |
|
---|
| 1371 | #ifndef DECLARED_FNRTSTROUTPUT /* duplicated in iprt/string.h */
|
---|
| 1372 | #define DECLARED_FNRTSTROUTPUT
|
---|
| 1373 | /**
|
---|
| 1374 | * Output callback.
|
---|
| 1375 | *
|
---|
| 1376 | * @returns number of bytes written.
|
---|
| 1377 | * @param pvArg User argument.
|
---|
| 1378 | * @param pachChars Pointer to an array of utf-8 characters.
|
---|
| 1379 | * @param cbChars Number of bytes in the character array pointed to by pachChars.
|
---|
| 1380 | */
|
---|
| 1381 | typedef DECLCALLBACK(size_t) FNRTSTROUTPUT(void *pvArg, const char *pachChars, size_t cbChars);
|
---|
| 1382 | /** Pointer to callback function. */
|
---|
| 1383 | typedef FNRTSTROUTPUT *PFNRTSTROUTPUT;
|
---|
| 1384 | #endif
|
---|
| 1385 |
|
---|
| 1386 | /**
|
---|
| 1387 | * Partial vsprintf worker implementation.
|
---|
| 1388 | *
|
---|
| 1389 | * @returns number of bytes formatted.
|
---|
| 1390 | * @param pfnOutput Output worker.
|
---|
| 1391 | * Called in two ways. Normally with a string an it's length.
|
---|
[628] | 1392 | * For termination, it's called with NULL for string, 0 for length.
|
---|
[1] | 1393 | * @param pvArg Argument to output worker.
|
---|
| 1394 | * @param pszFormat Format string.
|
---|
| 1395 | * @param args Argument list.
|
---|
| 1396 | */
|
---|
| 1397 | RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args);
|
---|
| 1398 |
|
---|
| 1399 | /**
|
---|
| 1400 | * Write log buffer to COM port.
|
---|
| 1401 | *
|
---|
| 1402 | * @param pach Pointer to the buffer to write.
|
---|
| 1403 | * @param cb Number of bytes to write.
|
---|
| 1404 | */
|
---|
| 1405 | RTDECL(void) RTLogWriteCom(const char *pach, size_t cb);
|
---|
| 1406 |
|
---|
| 1407 | /**
|
---|
| 1408 | * Prints a formatted string to the serial port used for logging.
|
---|
| 1409 | *
|
---|
| 1410 | * @returns Number of bytes written.
|
---|
| 1411 | * @param pszFormat Format string.
|
---|
| 1412 | * @param ... Optional arguments specified in the format string.
|
---|
| 1413 | */
|
---|
| 1414 | RTDECL(size_t) RTLogComPrintf(const char *pszFormat, ...);
|
---|
| 1415 |
|
---|
| 1416 | /**
|
---|
| 1417 | * Prints a formatted string to the serial port used for logging.
|
---|
| 1418 | *
|
---|
| 1419 | * @returns Number of bytes written.
|
---|
| 1420 | * @param pszFormat Format string.
|
---|
| 1421 | * @param args Optional arguments specified in the format string.
|
---|
| 1422 | */
|
---|
| 1423 | RTDECL(size_t) RTLogComPrintfV(const char *pszFormat, va_list args);
|
---|
| 1424 |
|
---|
| 1425 |
|
---|
| 1426 | #if 0 /* not implemented yet */
|
---|
| 1427 |
|
---|
| 1428 | /** Indicates that the semaphores shall be used to notify the other
|
---|
| 1429 | * part about buffer changes. */
|
---|
| 1430 | #define LOGHOOKBUFFER_FLAGS_SEMAPHORED 1
|
---|
| 1431 |
|
---|
| 1432 | /**
|
---|
| 1433 | * Log Hook Buffer.
|
---|
| 1434 | * Use to commuicate between the logger and a log consumer.
|
---|
| 1435 | */
|
---|
| 1436 | typedef struct RTLOGHOOKBUFFER
|
---|
| 1437 | {
|
---|
| 1438 | /** Write pointer. */
|
---|
| 1439 | volatile void *pvWrite;
|
---|
| 1440 | /** Read pointer. */
|
---|
| 1441 | volatile void *pvRead;
|
---|
| 1442 | /** Buffer start. */
|
---|
| 1443 | void *pvStart;
|
---|
| 1444 | /** Buffer end (exclusive). */
|
---|
| 1445 | void *pvEnd;
|
---|
| 1446 | /** Signaling semaphore used by the writer to wait on a full buffer.
|
---|
| 1447 | * Only used when indicated in flags. */
|
---|
| 1448 | void *pvSemWriter;
|
---|
| 1449 | /** Signaling semaphore used by the read to wait on an empty buffer.
|
---|
| 1450 | * Only used when indicated in flags. */
|
---|
| 1451 | void *pvSemReader;
|
---|
| 1452 | /** Buffer flags. Current reserved and set to zero. */
|
---|
| 1453 | volatile unsigned fFlags;
|
---|
| 1454 | } RTLOGHOOKBUFFER;
|
---|
| 1455 | /** Pointer to a log hook buffer. */
|
---|
| 1456 | typedef RTLOGHOOKBUFFER *PRTLOGHOOKBUFFER;
|
---|
| 1457 |
|
---|
| 1458 |
|
---|
| 1459 | /**
|
---|
| 1460 | * Register a logging hook.
|
---|
| 1461 | *
|
---|
| 1462 | * This type of logging hooks are expecting different threads acting
|
---|
| 1463 | * producer and consumer. They share a circular buffer which have two
|
---|
| 1464 | * pointers one for each end. When the buffer is full there are two
|
---|
| 1465 | * alternatives (indicated by a buffer flag), either wait for the
|
---|
| 1466 | * consumer to get it's job done, or to write a generic message saying
|
---|
| 1467 | * buffer overflow.
|
---|
| 1468 | *
|
---|
| 1469 | * Since the waiting would need a signal semaphore, we'll skip that for now.
|
---|
| 1470 | *
|
---|
| 1471 | * @returns iprt status code.
|
---|
| 1472 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
| 1473 | */
|
---|
| 1474 | RTDECL(int) RTLogRegisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
| 1475 |
|
---|
| 1476 | /**
|
---|
| 1477 | * Deregister a logging hook registerd with RTLogRegisterHook().
|
---|
| 1478 | *
|
---|
| 1479 | * @returns iprt status code.
|
---|
| 1480 | * @param pBuffer Pointer to a logger hook buffer.
|
---|
| 1481 | */
|
---|
| 1482 | RTDECL(int) RTLogDeregisterHook(PRTLOGGER pLogger, PRTLOGHOOKBUFFER pBuffer);
|
---|
| 1483 |
|
---|
| 1484 | #endif /* not implemented yet */
|
---|
| 1485 |
|
---|
| 1486 |
|
---|
| 1487 |
|
---|
| 1488 | /**
|
---|
| 1489 | * Write log buffer to a debugger (RTLOGDEST_DEBUGGER).
|
---|
| 1490 | *
|
---|
| 1491 | * @param pach What to write.
|
---|
| 1492 | * @param cb How much to write.
|
---|
| 1493 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
| 1494 | */
|
---|
| 1495 | RTDECL(void) RTLogWriteDebugger(const char *pach, size_t cb);
|
---|
| 1496 |
|
---|
| 1497 | /**
|
---|
| 1498 | * Write log buffer to a user defined output stream (RTLOGDEST_USER).
|
---|
| 1499 | *
|
---|
| 1500 | * @param pach What to write.
|
---|
| 1501 | * @param cb How much to write.
|
---|
| 1502 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
| 1503 | */
|
---|
| 1504 | RTDECL(void) RTLogWriteUser(const char *pach, size_t cb);
|
---|
| 1505 |
|
---|
| 1506 | /**
|
---|
| 1507 | * Write log buffer to stdout (RTLOGDEST_STDOUT).
|
---|
| 1508 | *
|
---|
| 1509 | * @param pach What to write.
|
---|
| 1510 | * @param cb How much to write.
|
---|
| 1511 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
| 1512 | */
|
---|
| 1513 | RTDECL(void) RTLogWriteStdOut(const char *pach, size_t cb);
|
---|
| 1514 |
|
---|
| 1515 | /**
|
---|
| 1516 | * Write log buffer to stdout (RTLOGDEST_STDERR).
|
---|
| 1517 | *
|
---|
| 1518 | * @param pach What to write.
|
---|
| 1519 | * @param cb How much to write.
|
---|
| 1520 | * @remark When linking statically, this function can be replaced by defining your own.
|
---|
| 1521 | */
|
---|
| 1522 | RTDECL(void) RTLogWriteStdErr(const char *pach, size_t cb);
|
---|
| 1523 |
|
---|
[3223] | 1524 | #ifdef VBOX
|
---|
[1] | 1525 |
|
---|
[3223] | 1526 | /**
|
---|
| 1527 | * Prints a formatted string to the backdoor port.
|
---|
| 1528 | *
|
---|
| 1529 | * @returns Number of bytes written.
|
---|
| 1530 | * @param pszFormat Format string.
|
---|
| 1531 | * @param ... Optional arguments specified in the format string.
|
---|
| 1532 | */
|
---|
| 1533 | RTDECL(size_t) RTLogBackdoorPrintf(const char *pszFormat, ...);
|
---|
| 1534 |
|
---|
| 1535 | /**
|
---|
| 1536 | * Prints a formatted string to the backdoor port.
|
---|
| 1537 | *
|
---|
| 1538 | * @returns Number of bytes written.
|
---|
| 1539 | * @param pszFormat Format string.
|
---|
| 1540 | * @param args Optional arguments specified in the format string.
|
---|
| 1541 | */
|
---|
| 1542 | RTDECL(size_t) RTLogBackdoorPrintfV(const char *pszFormat, va_list args);
|
---|
| 1543 |
|
---|
| 1544 | #endif /* VBOX */
|
---|
| 1545 |
|
---|
[1] | 1546 | __END_DECLS
|
---|
| 1547 |
|
---|
| 1548 | /** @} */
|
---|
| 1549 |
|
---|
| 1550 | #endif
|
---|
| 1551 |
|
---|