Changeset 8622 in vbox for trunk/include
- Timestamp:
- May 6, 2008 12:50:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/log.h
r8480 r8622 414 414 415 415 416 /** @def LOG_USE_C99 417 * Governs the use of variadic macros. 418 */ 419 #ifndef LOG_USE_C99 420 # if defined(RT_ARCH_AMD64) 421 # define LOG_USE_C99 422 # endif 423 #endif 424 425 416 426 /** @def LogIt 417 427 * Write to specific logger if group enabled. 418 428 */ 419 429 #ifdef LOG_ENABLED 420 # if defined( RT_ARCH_AMD64) || defined(LOG_USE_C99)430 # if defined(LOG_USE_C99) 421 431 # define _LogRemoveParentheseis(...) __VA_ARGS__ 422 432 # define _LogIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__) … … 529 539 /** @def LogWarning 530 540 * The same as Log(), but prepents a <tt>"WARNING! "</tt> string to the message. 531 * @param m custom log message in format <tt>("string\n" [, args])</tt> 532 * @todo use a Log macro with a variable argument list (requires MSVC8) to 533 * join two separate Log* calls and make this op atomic 534 */ 535 #define LogWarning(m) \ 536 do { Log(("WARNING! ")); Log(m); } while (0) 541 * 542 * @param a Custom log message in format <tt>("string\n" [, args])</tt>. 543 */ 544 #if defined(LOG_USE_C99) 545 # define LogWarning(a) \ 546 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "WARNING! %M", _LogRemoveParentheseis a ) 547 #else 548 # define LogWarning(a) \ 549 do { Log(("WARNING! ")); Log(a); } while (0) 550 #endif 537 551 538 552 /** @def LogTrace … … 546 560 /** @def LogTraceMsg 547 561 * The same as LogTrace but logs a custom log message right after the trace line. 548 * @param m custom log message in format <tt>("string\n" [, args])</tt> 549 * @todo use a Log macro with a variable argument list (requires MSVC8) to 550 * join two separate Log* calls and make this op atomic 551 */ 552 #define LogTraceMsg(m) \ 553 do { LogTrace(); LogFlow(m); } while (0) 562 * 563 * @param a Custom log message in format <tt>("string\n" [, args])</tt>. 564 */ 565 #ifdef LOG_USE_C99 566 # define LogTraceMsg(a) \ 567 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, ">>>>> %s (%d): %M" LOG_FN_FMT, __FILE__, __LINE__, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 568 #else 569 # define LogTraceMsg(a) \ 570 do { LogFlow((">>>>> %s (%d): " LOG_FN_FMT, __FILE__, __LINE__, __PRETTY_FUNCTION__)); LogFlow(a); } while (0) 571 #endif 554 572 555 573 /** @def LogFunc 556 574 * Level 1 logging inside C/C++ functions. 557 * Prepends the given log message with the function name followed by a semicolon 558 * and space. 559 * @param m log message in format <tt>("string\n" [, args])</tt> 560 * @todo use a Log macro with a variable argument list (requires MSVC8) to 561 * join two separate Log* calls and make this op atomic 562 */ 563 #define LogFunc(m) \ 564 do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(m); } while (0) 575 * 576 * Prepends the given log message with the function name followed by a 577 * semicolon and space. 578 * 579 * @param a Log message in format <tt>("string\n" [, args])</tt>. 580 */ 581 #ifdef LOG_USE_C99 582 # define LogFunc(a) \ 583 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 584 #else 585 # define LogFunc(a) \ 586 do { Log((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); Log(a); } while (0) 587 #endif 565 588 566 589 /** @def LogThisFunc 567 590 * The same as LogFunc but for class functions (methods): the resulting log 568 * line is additionally perpended with a hex value of |this| pointer. 569 * @param m log message in format <tt>("string\n" [, args])</tt> 570 * @todo use a Log macro with a variable argument list (requires MSVC8) to 571 * join two separate Log* calls and make this op atomic 572 */ 573 #define LogThisFunc(m) \ 574 do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(m); } while (0) 591 * line is additionally prepended with a hex value of |this| pointer. 592 * 593 * @param a Log message in format <tt>("string\n" [, args])</tt>. 594 */ 595 #ifdef LOG_USE_C99 596 # define LogThisFunc(a) \ 597 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 598 #else 599 # define LogThisFunc(a) \ 600 do { Log(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); Log(a); } while (0) 601 #endif 575 602 576 603 /** @def LogFlowFunc 577 604 * Macro to log the execution flow inside C/C++ functions. 578 * Prepends the given log message with the function name followed by a semicolon 579 * and space. 580 * @param m log message in format <tt>("string\n" [, args])</tt> 581 * @todo use a Log macro with a variable argument list (requires MSVC8) to 582 * join two separate Log* calls and make this op atomic 583 */ 584 #define LogFlowFunc(m) \ 585 do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(m); } while (0) 605 * 606 * Prepends the given log message with the function name followed by 607 * a semicolon and space. 608 * 609 * @param a Log message in format <tt>("string\n" [, args])</tt>. 610 */ 611 #ifdef LOG_USE_C99 612 # define LogFlowFunc(a) \ 613 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, LOG_FN_FMT ": %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 614 #else 615 # define LogFlowFunc(a) \ 616 do { LogFlow((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogFlow(a); } while (0) 617 #endif 586 618 587 619 /** @def LogWarningFunc 588 620 * The same as LogWarning(), but prepents the log message with the function name. 589 * @param m log message in format <tt>("string\n" [, args])</tt> 590 * @todo use a Log macro with a variable argument list (requires MSVC8) to 591 * join two separate Log* calls and make this op atomic 592 */ 593 #define LogWarningFunc(m) \ 594 do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(m); } while (0) 621 * 622 * @param a Log message in format <tt>("string\n" [, args])</tt>. 623 */ 624 #ifdef LOG_USE_C99 625 # define LogWarningFunc(a) \ 626 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, LOG_FN_FMT ": WARNING! %M", __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 627 #else 628 # define LogWarningFunc(a) \ 629 do { Log((LOG_FN_FMT ": WARNING! ", __PRETTY_FUNCTION__)); Log(a); } while (0) 630 #endif 595 631 596 632 /** @def LogFlowThisFunc 597 633 * The same as LogFlowFunc but for class functions (methods): the resulting log 598 * line is additionally perpended with a hex value of |this| pointer. 599 * @param m log message in format <tt>("string\n" [, args])</tt> 600 * @todo use a Log macro with a variable argument list (requires MSVC8) to 601 * join two separate Log* calls and make this op atomic 602 */ 603 #define LogFlowThisFunc(m) \ 604 do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(m); } while (0) 634 * line is additionally prepended with a hex value of |this| pointer. 635 * 636 * @param a Log message in format <tt>("string\n" [, args])</tt>. 637 */ 638 #ifdef LOG_USE_C99 639 # define LogFlowThisFunc(a) \ 640 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_FLOW, LOG_GROUP, "{%p} " LOG_FN_FMT ": %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 641 #else 642 # define LogFlowThisFunc(a) \ 643 do { LogFlow(("{%p} " LOG_FN_FMT ": ", this, __PRETTY_FUNCTION__)); LogFlow(a); } while (0) 644 #endif 605 645 606 646 /** @def LogWarningThisFunc 607 647 * The same as LogWarningFunc() but for class functions (methods): the resulting 608 * log line is additionally perpended with a hex value of |this| pointer. 609 * @param m log message in format <tt>("string\n" [, args])</tt> 610 * @todo use a Log macro with a variable argument list (requires MSVC8) to 611 * join two separate Log* calls and make this op atomic 612 */ 613 #define LogWarningThisFunc(m) \ 614 do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(m); } while (0) 615 616 /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function */ 648 * log line is additionally prepended with a hex value of |this| pointer. 649 * 650 * @param a Log message in format <tt>("string\n" [, args])</tt>. 651 */ 652 #ifdef LOG_USE_C99 653 # define LogWarningThisFunc(a) \ 654 _LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP, "{%p} " LOG_FN_FMT ": WARNING! %M", this, __PRETTY_FUNCTION__, _LogRemoveParentheseis a ) 655 #else 656 # define LogWarningThisFunc(a) \ 657 do { Log(("{%p} " LOG_FN_FMT ": WARNING! ", this, __PRETTY_FUNCTION__)); Log(a); } while (0) 658 #endif 659 660 /** Shortcut to |LogFlowFunc ("ENTER\n")|, marks the beginnig of the function. */ 617 661 #define LogFlowFuncEnter() LogFlowFunc(("ENTER\n")) 618 662 619 /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function */663 /** Shortcut to |LogFlowFunc ("LEAVE\n")|, marks the end of the function. */ 620 664 #define LogFlowFuncLeave() LogFlowFunc(("LEAVE\n")) 621 665 622 /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function */666 /** Shortcut to |LogFlowThisFunc ("ENTER\n")|, marks the beginnig of the function. */ 623 667 #define LogFlowThisFuncEnter() LogFlowThisFunc(("ENTER\n")) 624 668 625 /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function */669 /** Shortcut to |LogFlowThisFunc ("LEAVE\n")|, marks the end of the function. */ 626 670 #define LogFlowThisFuncLeave() LogFlowThisFunc(("LEAVE\n")) 627 671 … … 629 673 * Helper macro to print the current reference count of the given COM object 630 674 * to the log file. 631 * @param obj object in question (must be a pointer to an IUnknown subclass 632 * or simply define COM-style AddRef() and Release() methods) 675 * 676 * @param pObj Pointer to the object in question (must be a pointer to an 677 * IUnknown subclass or simply define COM-style AddRef() and 678 * Release() methods) 679 * 633 680 * @note Use it only for temporary debugging. It leaves dummy code even if 634 681 * logging is disabled. 635 682 */ 636 #define LogObjRefCnt( obj) \683 #define LogObjRefCnt(pObj) \ 637 684 do { \ 638 int refc = ( obj)->AddRef(); -- refc; \639 LogFlow((# obj "{%p}.refCnt=%d\n", (obj), refc)); \640 ( obj)->Release(); \685 int refc = (pObj)->AddRef(); \ 686 LogFlow((#pObj "{%p}.refCnt=%d\n", (pObj), refc - 1)); \ 687 (pObj)->Release(); \ 641 688 } while (0) 642 689 … … 721 768 * Write to specific logger if group enabled. 722 769 */ 723 #if defined( RT_ARCH_AMD64) || defined(LOG_USE_C99)770 #if defined(LOG_USE_C99) 724 771 # define _LogRelRemoveParentheseis(...) __VA_ARGS__ 725 772 # define _LogRelIt(pvInst, fFlags, iGroup, ...) RTLogLoggerEx((PRTLOGGER)pvInst, fFlags, iGroup, __VA_ARGS__) … … 792 839 /** @def LogRelThisFunc 793 840 * The same as LogRelFunc but for class functions (methods): the resulting log 794 * line is additionally p erpended with a hex value of |this| pointer.841 * line is additionally prepended with a hex value of |this| pointer. 795 842 */ 796 843 #define LogRelThisFunc(a) \
Note:
See TracChangeset
for help on using the changeset viewer.