| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
#ifndef ___iprt_log_h |
|---|
| 31 |
#define ___iprt_log_h |
|---|
| 32 |
|
|---|
| 33 |
#include <iprt/cdefs.h> |
|---|
| 34 |
#include <iprt/types.h> |
|---|
| 35 |
#include <iprt/stdarg.h> |
|---|
| 36 |
|
|---|
| 37 |
__BEGIN_DECLS |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
typedef enum RTLOGGROUP |
|---|
| 56 |
{ |
|---|
| 57 |
|
|---|
| 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 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 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", \ |
|---|
| 93 |
"RT_THREAD", \ |
|---|
| 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 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
#ifndef LOG_GROUP |
|---|
| 124 |
# define LOG_GROUP RTLOGGROUP_DEFAULT |
|---|
| 125 |
#endif |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
#ifndef LOG_INSTANCE |
|---|
| 131 |
# define LOG_INSTANCE NULL |
|---|
| 132 |
#endif |
|---|
| 133 |
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
#ifndef LOG_REL_INSTANCE |
|---|
| 138 |
# define LOG_REL_INSTANCE NULL |
|---|
| 139 |
#endif |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
#ifndef LOG_FN_FMT |
|---|
| 146 |
# define LOG_FN_FMT "%Rfn" |
|---|
| 147 |
#endif |
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
#ifdef IN_RC |
|---|
| 151 |
typedef struct RTLOGGERRC RTLOGGER; |
|---|
| 152 |
#else |
|---|
| 153 |
typedef struct RTLOGGER RTLOGGER; |
|---|
| 154 |
#endif |
|---|
| 155 |
|
|---|
| 156 |
typedef RTLOGGER *PRTLOGGER; |
|---|
| 157 |
|
|---|
| 158 |
typedef const RTLOGGER *PCRTLOGGER; |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
typedef struct RTLOGGERRC RTLOGGERRC; |
|---|
| 163 |
|
|---|
| 164 |
typedef RTLOGGERRC *PRTLOGGERRC; |
|---|
| 165 |
|
|---|
| 166 |
typedef const RTLOGGERRC *PCRTLOGGERRC; |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
typedef DECLCALLBACK(void) FNRTLOGGER(const char *pszFormat, ...); |
|---|
| 176 |
|
|---|
| 177 |
typedef FNRTLOGGER *PFNRTLOGGER; |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
|
|---|
| 184 |
typedef DECLCALLBACK(void) FNRTLOGFLUSH(PRTLOGGER pLogger); |
|---|
| 185 |
|
|---|
| 186 |
typedef FNRTLOGFLUSH *PFNRTLOGFLUSH; |
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
typedef DECLCALLBACK(void) FNRTLOGFLUSHGC(PRTLOGGERRC pLogger); |
|---|
| 194 |
|
|---|
| 195 |
typedef RCPTRTYPE(FNRTLOGFLUSHGC *) PFNRTLOGFLUSHGC; |
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
struct RTLOGGERRC |
|---|
| 202 |
{ |
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
char achScratch[16384]; |
|---|
| 206 |
|
|---|
| 207 |
RTUINT offScratch; |
|---|
| 208 |
|
|---|
| 209 |
RTUINT fPendingPrefix; |
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
RCPTRTYPE(PFNRTLOGGER) pfnLogger; |
|---|
| 215 |
|
|---|
| 216 |
PFNRTLOGFLUSHGC pfnFlush; |
|---|
| 217 |
|
|---|
| 218 |
uint32_t u32Magic; |
|---|
| 219 |
|
|---|
| 220 |
RTUINT fFlags; |
|---|
| 221 |
|
|---|
| 222 |
RTUINT cGroups; |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
RTUINT afGroups[1]; |
|---|
| 227 |
}; |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
#define RTLOGGERRC_MAGIC 0x19320731 |
|---|
| 231 |
|
|---|
| 232 |
|
|---|
| 233 |
|
|---|
| 234 |
#ifndef IN_RC |
|---|
| 235 |
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 |
struct RTLOGGER |
|---|
| 239 |
{ |
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 |
char achScratch[16384]; |
|---|
| 243 |
|
|---|
| 244 |
RTUINT offScratch; |
|---|
| 245 |
|
|---|
| 246 |
RTUINT fPendingPrefix; |
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
PFNRTLOGGER pfnLogger; |
|---|
| 253 |
|
|---|
| 254 |
PFNRTLOGFLUSH pfnFlush; |
|---|
| 255 |
|
|---|
| 256 |
RTSEMFASTMUTEX MutexSem; |
|---|
| 257 |
|
|---|
| 258 |
uint32_t u32Magic; |
|---|
| 259 |
|
|---|
| 260 |
RTUINT fFlags; |
|---|
| 261 |
|
|---|
| 262 |
RTUINT fDestFlags; |
|---|
| 263 |
|
|---|
| 264 |
RTFILE File; |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
char *pszFilename; |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
const char * const *papszGroups; |
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
RTUINT cMaxGroups; |
|---|
| 274 |
|
|---|
| 275 |
RTUINT cGroups; |
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
RTUINT afGroups[1]; |
|---|
| 280 |
}; |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
#define RTLOGGER_MAGIC 0x19281207 |
|---|
| 284 |
|
|---|
| 285 |
#endif |
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
|
|---|
| 291 |
typedef enum RTLOGFLAGS |
|---|
| 292 |
{ |
|---|
| 293 |
|
|---|
| 294 |
RTLOGFLAGS_DISABLED = 0x00000001, |
|---|
| 295 |
|
|---|
| 296 |
RTLOGFLAGS_BUFFERED = 0x00000002, |
|---|
| 297 |
|
|---|
| 298 |
RTLOGFLAGS_USECRLF = 0x00000010, |
|---|
| 299 |
|
|---|
| 300 |
RTLOGFLAGS_APPEND = 0x00000020, |
|---|
| 301 |
|
|---|
| 302 |
RTLOGFLAGS_REL_TS = 0x00000040, |
|---|
| 303 |
|
|---|
| 304 |
RTLOGFLAGS_DECIMAL_TS = 0x00000080, |
|---|
| 305 |
|
|---|
| 306 |
RTLOGFLAGS_PREFIX_LOCK_COUNTS = 0x00008000, |
|---|
| 307 |
|
|---|
| 308 |
RTLOGFLAGS_PREFIX_CPUID = 0x00010000, |
|---|
| 309 |
|
|---|
| 310 |
RTLOGFLAGS_PREFIX_PID = 0x00020000, |
|---|
| 311 |
|
|---|
| 312 |
RTLOGFLAGS_PREFIX_FLAG_NO = 0x00040000, |
|---|
| 313 |
|
|---|
| 314 |
RTLOGFLAGS_PREFIX_FLAG = 0x00080000, |
|---|
| 315 |
|
|---|
| 316 |
RTLOGFLAGS_PREFIX_GROUP_NO = 0x00100000, |
|---|
| 317 |
|
|---|
| 318 |
RTLOGFLAGS_PREFIX_GROUP = 0x00200000, |
|---|
| 319 |
|
|---|
| 320 |
RTLOGFLAGS_PREFIX_TID = 0x00400000, |
|---|
| 321 |
|
|---|
| 322 |
RTLOGFLAGS_PREFIX_THREAD = 0x00800000, |
|---|
| 323 |
|
|---|
| 324 |
RTLOGFLAGS_PREFIX_TIME_PROG = 0x04000000, |
|---|
| 325 |
|
|---|
| 326 |
RTLOGFLAGS_PREFIX_TIME = 0x08000000, |
|---|
| 327 |
|
|---|
| 328 |
RTLOGFLAGS_PREFIX_MS_PROG = 0x10000000, |
|---|
| 329 |
|
|---|
| 330 |
RTLOGFLAGS_PREFIX_TSC = 0x20000000, |
|---|
| 331 |
|
|---|
| 332 |
RTLOGFLAGS_PREFIX_TS = 0x40000000, |
|---|
| 333 |
|
|---|
| 334 |
RTLOGFLAGS_PREFIX_MASK = 0x7cff8000 |
|---|
| 335 |
} RTLOGFLAGS; |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
typedef enum RTLOGGRPFLAGS |
|---|
| 341 |
{ |
|---|
| 342 |
|
|---|
| 343 |
RTLOGGRPFLAGS_ENABLED = 0x00000001, |
|---|
| 344 |
|
|---|
| 345 |
RTLOGGRPFLAGS_LEVEL_1 = 0x00000002, |
|---|
| 346 |
|
|---|
| 347 |
RTLOGGRPFLAGS_LEVEL_2 = 0x00000004, |
|---|
| 348 |
|
|---|
| 349 |
RTLOGGRPFLAGS_LEVEL_3 = 0x00000008, |
|---|
| 350 |
|
|---|
| 351 |
RTLOGGRPFLAGS_LEVEL_4 = 0x00000010, |
|---|
| 352 |
|
|---|
| 353 |
RTLOGGRPFLAGS_LEVEL_5 = 0x00000020, |
|---|
| 354 |
|
|---|
| 355 |
RTLOGGRPFLAGS_LEVEL_6 = 0x00000040, |
|---|
| 356 |
|
|---|
| 357 |
RTLOGGRPFLAGS_FLOW = 0x00000080, |
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
RTLOGGRPFLAGS_LELIK = 0x00000100, |
|---|
| 361 |
|
|---|
| 362 |
RTLOGGRPFLAGS_MICHAEL = 0x00000200, |
|---|
| 363 |
|
|---|
| 364 |
RTLOGGRPFLAGS_DMIK = 0x00000400, |
|---|
| 365 |
|
|---|
| 366 |
RTLOGGRPFLAGS_SUNLOVER = 0x00000800, |
|---|
| 367 |
|
|---|
| 368 |
RTLOGGRPFLAGS_ACHIM = 0x00001000, |
|---|
| 369 |
|
|---|
| 370 |
RTLOGGRPFLAGS_SANDER = 0x00002000, |
|---|
| 371 |
|
|---|
| 372 |
RTLOGGRPFLAGS_KLAUS = 0x00004000, |
|---|
| 373 |
|
|---|
| 374 |
RTLOGGRPFLAGS_FRANK = 0x00008000, |
|---|
| 375 |
|
|---|
| 376 |
RTLOGGRPFLAGS_BIRD = 0x00010000, |
|---|
| 377 |
|
|---|
| 378 |
RTLOGGRPFLAGS_ALEKSEY = 0x00020000, |
|---|
| 379 |
|
|---|
| 380 |
RTLOGGRPFLAGS_NONAME = 0x00040000 |
|---|
| 381 |
} RTLOGGRPFLAGS; |
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
|
|---|
| 386 |
typedef enum RTLOGDEST |
|---|
| 387 |
{ |
|---|
| 388 |
|
|---|
| 389 |
RTLOGDEST_FILE = 0x00000001, |
|---|
| 390 |
|
|---|
| 391 |
RTLOGDEST_STDOUT = 0x00000002, |
|---|
| 392 |
|
|---|
| 393 |
RTLOGDEST_STDERR = 0x00000004, |
|---|
| 394 |
|
|---|
| 395 |
RTLOGDEST_DEBUGGER = 0x00000008, |
|---|
| 396 |
|
|---|
| 397 |
RTLOGDEST_COM = 0x00000010, |
|---|
| 398 |
|
|---|
| 399 |
RTLOGDEST_DUMMY = 0x20000000, |
|---|
| 400 |
|
|---|
| 401 |
RTLOGDEST_USER = 0x40000000 |
|---|
| 402 |
} RTLOGDEST; |
|---|
| 403 |
|
|---|
| 404 |
|
|---|
| 405 |
RTDECL(void) RTLogPrintfEx(void *pvInstance, unsigned fFlags, unsigned iGroup, const char *pszFormat, ...); |
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 |
#ifdef DOXYGEN_RUNNING |
|---|
| 409 |
# define LOG_DISABLED |
|---|
| 410 |
# define LOG_ENABLED |
|---|
| 411 |
# define LOG_ENABLE_FLOW |
|---|
| 412 |
#endif |
|---|
| 413 |
|
|---|
| 414 |
|
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
|
|---|
| 418 |
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 |
|
|---|
| 422 |
|
|---|
| 423 |
|
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 |
|
|---|
| 428 |
|
|---|
| 429 |
|
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
#if (defined(DEBUG) || defined(LOG_ENABLED)) && !defined(LOG_DISABLED) |
|---|
| 436 |
# undef LOG_DISABLED |
|---|
| 437 |
# undef LOG_ENABLED |
|---|
| 438 |
# define LOG_ENABLED |
|---|
| 439 |
#else |
|---|
| 440 |
# undef LOG_ENABLED |
|---|
| 441 |
# undef LOG_DISABLED |
|---|
| 442 |
# define LOG_DISABLED |
|---|
| 443 |
#endif |
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 |
|
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
#ifndef LOG_USE_C99 |
|---|
| 450 |
# if defined(RT_ARCH_AMD64) |
|---|
| 451 |
# define LOG_USE_C99 |
|---|
| 452 |
# endif |
|---|
| 453 |
#endif |
|---|
| 454 |
|
|---|
| 455 |
|
|---|
| 456 |
|
|---|
| 457 |
|
|---|
| 458 |
|
|---|
| 459 |
#ifdef LOG_ENABLED |
|---|
| 460 |
# if defined(LOG_USE_C99) |
|---|
| 461 |
# define _LogRemoveParentheseis(...) __VA_ARGS__ |
|---|
| 462 |
# define _LogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__) |
|---|
| 463 |
# define LogIt(pvInst, fFlags, iGroup, fmtargs) _LogIt(pvInst, fFlags, iGroup, _LogRemoveParentheseis fmtargs) |
|---|
| 464 |
# define _LogItAlways(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, ~0U, __VA_ARGS__) |
|---|
| 465 |
# define LogItAlways(pvInst, fFlags, iGroup, fmtargs) _LogItAlways(pvInst, fFlags, iGroup, _LogRemoveParentheseis fmtargs) |
|---|
| 466 |
|
|---|
| 467 |
# else |
|---|
| 468 |
# define LogIt(pvInst, fFlags, iGroup, fmtargs) \ |
|---|
| 469 |
do \ |
|---|
| 470 |
{ \ |
|---|
| 471 |
register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \ |
|---|
| 472 |
if (LogIt_pLogger) \ |
|---|
| 473 |
{ \ |
|---|
| 474 |
register unsigned LogIt_fFlags = LogIt_pLogger->afGroups[(unsigned)(iGroup) < LogIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \ |
|---|
| 475 |
if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \ |
|---|
| 476 |
LogIt_pLogger->pfnLogger fmtargs; \ |
|---|
| 477 |
} \ |
|---|
| 478 |
} while (0) |
|---|
| 479 |
# define LogItAlways(pvInst, fFlags, iGroup, fmtargs) \ |
|---|
| 480 |
do \ |
|---|
| 481 |
{ \ |
|---|
| 482 |
register PRTLOGGER LogIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogDefaultInstance(); \ |
|---|
| 483 |
if (LogIt_pLogger) \ |
|---|
| 484 |
LogIt_pLogger->pfnLogger fmtargs; \ |
|---|
| 485 |
} while (0) |
|---|
| 486 |
# endif |
|---|
| 487 |
#else |
|---|
| 488 |
# define LogIt(pvInst, fFlags, iGroup, fmtargs) do { } while (0) |
|---|
| 489 |
# define LogItAlways(pvInst, fFlags, iGroup, fmtargs) do { } while (0) |
|---|
| 490 |
# if defined(LOG_USE_C99) |
|---|
| 491 |
# define _LogRemoveParentheseis(...) __VA_ARGS__ |
|---|
| 492 |
# define _LogIt(pvInst, fFlags, iGroup, ...) do { } while (0) |
|---|
| 493 |
# define _LogItAlways(pvInst, fFlags, iGroup, ...) do { } while (0) |
|---|
| 494 |
# endif |
|---|
| 495 |
#endif |
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
|
|---|
| 501 |
#define LogAlways(a) LogItAlways(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a) |
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
#define Log(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a) |
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
|
|---|
| 510 |
|
|---|
| 511 |
#define Log2(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP, a) |
|---|
| 512 |
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
#define Log3(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP, a) |
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 |
#define Log4(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP, a) |
|---|
| 522 |
|
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
#define Log5(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP, a) |
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
#define Log6(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP, a) |
|---|
| 532 |
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 |
#define LogFlow(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, a) |
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 |
|
|---|
| 540 |
|
|---|
| 541 |
#define LogLelik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LELIK, LOG_GROUP, a) |
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 |
|
|---|
| 547 |
#define LogMichael(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_MICHAEL, LOG_GROUP, a) |
|---|
| 548 |
|
|---|
| 549 |
|
|---|
| 550 |
|
|---|
| 551 |
|
|---|
| 552 |
#define LogDmik(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_DMIK, LOG_GROUP, a) |
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 |
|
|---|
| 557 |
#define LogSunlover(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SUNLOVER, LOG_GROUP, a) |
|---|
| 558 |
|
|---|
| 559 |
|
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
#define LogAchim(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ACHIM, LOG_GROUP, a) |
|---|
| 563 |
|
|---|
| 564 |
|
|---|
| 565 |
|
|---|
| 566 |
|
|---|
| 567 |
#define LogSander(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_SANDER, LOG_GROUP, a) |
|---|
| 568 |
|
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
#define LogKlaus(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_KLAUS, LOG_GROUP, a) |
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
|
|---|
| 576 |
|
|---|
| 577 |
#define LogFrank(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FRANK, LOG_GROUP, a) |
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 |
|
|---|
| 581 |
|
|---|
| 582 |
#define LogBird(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_BIRD, LOG_GROUP, a) |
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
#define LogAleksey(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_ALEKSEY, LOG_GROUP, a) |
|---|
| 588 |
|
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
|
|---|
| 592 |
#define LogNoName(a) LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_NONAME, LOG_GROUP, a) |
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| 596 |
|
|---|
| 597 |
|
|---|
| 598 |
|
|---|
| 599 |
|
|---|
| 600 |
#if defined(LOG_USE_C99) |
|---|
| 601 |
# define LogWarning(a) \ |
|---|
| 602 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a ) |
|---|
| 603 |
#else |
|---|
| 604 |
# define LogWarning(a) \ |
|---|
| 605 |
do { Log(("WARNING! ")); Log(a); } while (0) |
|---|
| 606 |
#endif |
|---|
| 607 |
|
|---|
| 608 |
|
|---|
| 609 |
|
|---|
| 610 |
|
|---|
| 611 |
|
|---|
| 612 |
|
|---|
| 613 |
#define LogTrace() \ |
|---|
| 614 |
LogFlow((">>>>> %s (%d): " LOG_FN_FMT "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)) |
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
|
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 |
|
|---|
| 621 |
#ifdef LOG_USE_C99 |
|---|
| 622 |
# define LogTraceMsg(a) \ |
|---|
| 623 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, ">>>>> %s (%d): " LOG_FN_FMT ": %M", __FILE__, __LINE__, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 624 |
#else |
|---|
| 625 |
# define LogTraceMsg(a) \ |
|---|
| 626 |
do { LogFlow((">>>>> %s (%d): " LOG_FN_FMT ": ", __FILE__, __LINE__, __PRETTY_FUNCTION__)); LogFlow(a); } while (0) |
|---|
| 627 |
#endif |
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 |
|
|---|
| 631 |
|
|---|
| 632 |
|
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 |
|
|---|
| 637 |
#ifdef LOG_USE_C99 |
|---|
| 638 |
# define LogFunc(a) \ |
|---|
| 639 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 640 |
#else |
|---|
| 641 |
# define LogFunc(a) \ |
|---|
| 642 |
do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0) |
|---|
| 643 |
#endif |
|---|
| 644 |
|
|---|
| 645 |
|
|---|
| 646 |
|
|---|
| 647 |
|
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 |
#ifdef LOG_USE_C99 |
|---|
| 652 |
# define LogThisFunc(a) \ |
|---|
| 653 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 654 |
#else |
|---|
| 655 |
# define LogThisFunc(a) \ |
|---|
| 656 |
do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(a); } while (0) |
|---|
| 657 |
#endif |
|---|
| 658 |
|
|---|
| 659 |
|
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 |
|
|---|
| 664 |
|
|---|
| 665 |
|
|---|
| 666 |
|
|---|
| 667 |
#ifdef LOG_USE_C99 |
|---|
| 668 |
# define LogFlowFunc(a) \ |
|---|
| 669 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 670 |
#else |
|---|
| 671 |
# define LogFlowFunc(a) \ |
|---|
| 672 |
do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0) |
|---|
| 673 |
#endif |
|---|
| 674 |
|
|---|
| 675 |
|
|---|
| 676 |
|
|---|
| 677 |
|
|---|
| 678 |
|
|---|
| 679 |
|
|---|
| 680 |
#ifdef LOG_USE_C99 |
|---|
| 681 |
# define LogWarningFunc(a) \ |
|---|
| 682 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 683 |
#else |
|---|
| 684 |
# define LogWarningFunc(a) \ |
|---|
| 685 |
do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0) |
|---|
| 686 |
#endif |
|---|
| 687 |
|
|---|
| 688 |
|
|---|
| 689 |
|
|---|
| 690 |
|
|---|
| 691 |
|
|---|
| 692 |
|
|---|
| 693 |
|
|---|
| 694 |
#ifdef LOG_USE_C99 |
|---|
| 695 |
# define LogFlowThisFunc(a) \ |
|---|
| 696 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 697 |
#else |
|---|
| 698 |
# define LogFlowThisFunc(a) \ |
|---|
| 699 |
do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(a); } while (0) |
|---|
| 700 |
#endif |
|---|
| 701 |
|
|---|
| 702 |
|
|---|
| 703 |
|
|---|
| 704 |
|
|---|
| 705 |
|
|---|
| 706 |
|
|---|
| 707 |
|
|---|
| 708 |
#ifdef LOG_USE_C99 |
|---|
| 709 |
# define LogWarningThisFunc(a) \ |
|---|
| 710 |
_LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) |
|---|
| 711 |
#else |
|---|
| 712 |
# define LogWarningThisFunc(a) \ |
|---|
| 713 |
do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(a); } while (0) |
|---|
| 714 |
#endif |
|---|
| 715 |
|
|---|
| 716 |
|
|---|
| 717 |
#define LogFlowFuncEnter() LogFlowFunc(("ENTER\n")) |
|---|
| 718 |
|
|---|
| 719 |
|
|---|
| 720 |
#define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n")) |
|---|
| 721 |
|
|---|
| 722 |
|
|---|
| 723 |
#define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n")) |
|---|
| 724 |
|
|---|
| 725 |
|
|---|
| 726 |
#define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n")) |
|---|
| 727 |
|
|---|
| 728 |
|
|---|
| 729 |
|
|---|
| 730 |
|
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
|
|---|
| 734 |
|
|---|
| 735 |
|
|---|
| 736 |
|
|---|
| 737 |
|
|---|
| 738 |
|
|---|
| 739 |
#define LogObjRefCnt(pObj) \ |
|---|
| 740 |
do { \ |
|---|
| 741 |
int refc = (pObj)->AddRef(); \ |
|---|
| 742 |
LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), refc - 1)); \ |
|---|
| 743 |
(pObj)->Release(); \ |
|---|
| 744 |
} while (0) |
|---|
| 745 |
|
|---|
| 746 |
|
|---|
| 747 |
|
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 |
#ifdef LOG_ENABLED |
|---|
| 751 |
# define LogIsItEnabled(pvInst, fFlags, iGroup) \ |
|---|
| 752 |
LogIsItEnabledInternal((pvInst), (unsigned)(iGroup), (unsigned)(fFlags)) |
|---|
| 753 |
#else |
|---|
| 754 |
# define LogIsItEnabled(pvInst, fFlags, iGroup) (false) |
|---|
| 755 |
#endif |
|---|
| 756 |
|
|---|
| 757 |
|
|---|
| 758 |
|
|---|
| 759 |
|
|---|
| 760 |
#define LogIsEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP) |
|---|
| 761 |
|
|---|
| 762 |
|
|---|
| 763 |
|
|---|
| 764 |
|
|---|
| 765 |
#define LogIs2Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP) |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
|
|---|
| 769 |
|
|---|
| 770 |
#define LogIs3Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_3, LOG_GROUP) |
|---|
| 771 |
|
|---|
| 772 |
|
|---|
| 773 |
|
|---|
| 774 |
|
|---|
| 775 |
#define LogIs4Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_4, LOG_GROUP) |
|---|
| 776 |
|
|---|
| 777 |
|
|---|
| 778 |
|
|---|
| 779 |
|
|---|
| 780 |
#define LogIs5Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_5, LOG_GROUP) |
|---|
| 781 |
|
|---|
| 782 |
|
|---|
| 783 |
|
|---|
| 784 |
|
|---|
| 785 |
#define LogIs6Enabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_6, LOG_GROUP) |
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 |
|
|---|
| 789 |
|
|---|
| 790 |
#define LogIsFlowEnabled() LogIsItEnabled(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP) |
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 |
|
|---|
| 796 |
|
|---|
| 797 |
|
|---|
| 798 |
|
|---|
| 799 |
#ifdef DOXYGEN_RUNNING |
|---|
| 800 |
# define RTLOG_REL_DISABLED |
|---|
| 801 |
# define RTLOG_REL_ENABLED |
|---|
| 802 |
#endif |
|---|
| 803 |
|
|---|
| 804 |
|
|---|
| 805 |
|
|---|
| 806 |
|
|---|
| 807 |
|
|---|
| 808 |
|
|---|
| 809 |
|
|---|
| 810 |
|
|---|
| 811 |
|
|---|
| 812 |
|
|---|
| 813 |
|
|---|
| 814 |
|
|---|
| 815 |
|
|---|
| 816 |
#if !defined(RTLOG_REL_DISABLED) || defined(RTLOG_REL_ENABLED) |
|---|
| 817 |
# undef RTLOG_REL_DISABLED |
|---|
| 818 |
# undef RTLOG_REL_ENABLED |
|---|
| 819 |
# define RTLOG_REL_ENABLED |
|---|
| 820 |
#else |
|---|
| 821 |
# undef RTLOG_REL_ENABLED |
|---|
| 822 |
# undef RTLOG_REL_DISABLED |
|---|
| 823 |
# define RTLOG_REL_DISABLED |
|---|
| 824 |
#endif |
|---|
| 825 |
|
|---|
| 826 |
|
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
|
|---|
| 830 |
#ifdef RTLOG_REL_ENABLED |
|---|
| 831 |
# if defined(LOG_USE_C99) |
|---|
| 832 |
# define _LogRelRemoveParentheseis(...) __VA_ARGS__ |
|---|
| 833 |
# define _LogRelIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__) |
|---|
| 834 |
# define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \ |
|---|
| 835 |
do \ |
|---|
| 836 |
{ \ |
|---|
| 837 |
PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \ |
|---|
| 838 |
if (LogRelIt_pLogger) \ |
|---|
| 839 |
_LogRelIt(LogRelIt_pLogger, fFlags, iGroup, _LogRelRemoveParentheseis fmtargs); \ |
|---|
| 840 |
LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \ |
|---|
| 841 |
} while (0) |
|---|
| 842 |
# else |
|---|
| 843 |
# define LogRelIt(pvInst, fFlags, iGroup, fmtargs) \ |
|---|
| 844 |
do \ |
|---|
| 845 |
{ \ |
|---|
| 846 |
PRTLOGGER LogRelIt_pLogger = (PRTLOGGER)(pvInst) ? (PRTLOGGER)(pvInst) : RTLogRelDefaultInstance(); \ |
|---|
| 847 |
if (LogRelIt_pLogger) \ |
|---|
| 848 |
{ \ |
|---|
| 849 |
unsigned LogIt_fFlags = LogRelIt_pLogger->afGroups[(unsigned)(iGroup) < LogRelIt_pLogger->cGroups ? (unsigned)(iGroup) : 0]; \ |
|---|
| 850 |
if ((LogIt_fFlags & ((fFlags) | RTLOGGRPFLAGS_ENABLED)) == ((fFlags) | RTLOGGRPFLAGS_ENABLED)) \ |
|---|
| 851 |
LogRelIt_pLogger->pfnLogger fmtargs; \ |
|---|
| 852 |
} \ |
|---|
| 853 |
LogIt(LOG_INSTANCE, fFlags, iGroup, fmtargs); \ |
|---|
| 854 |
} while (0) |
|---|
| 855 |
# endif |
|---|
| 856 |
#else |
|---|
| 857 |
# define LogRelIt(pvInst, fFlags, iGroup, fmtargs) do { } while (0) |
|---|
| 858 |
# if defined(LOG_USE_C99) |
|---|
| 859 |
# define _LogRelRemoveParentheseis(...) __VA_ARGS__ |
|---|
| 860 |
# define _LogRelIt(pvInst, fFlags, iGroup, ...) do { } while (0) |
|---|
| 861 |
# endif |
|---|
| 862 |
#endif |
|---|
| 863 |
|
|---|
| 864 |
|
|---|
| 865 |
|
|---|
| 866 |
|
|---|
| 867 |
|
|---|
| 868 |
#define LogRel(a) LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, a) |
|---|
| 869 |
|
|---|
| 870 |
|
|---|
| 871 |
|
|---|
| 872 |
|
|---|
| 873 |
#define LogRel2(a) LogRelIt(LOG_R |
|---|