Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: base/logging.h

Issue 2656053002: NullStream
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/time/time.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ 420 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
421 ::logging::GetLastSystemErrorCode()).stream() 421 ::logging::GetLastSystemErrorCode()).stream()
422 #endif 422 #endif
423 423
424 #define PLOG(severity) \ 424 #define PLOG(severity) \
425 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) 425 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
426 426
427 #define PLOG_IF(severity, condition) \ 427 #define PLOG_IF(severity, condition) \
428 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) 428 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
429 429
430 BASE_EXPORT extern std::ostream* g_swallow_stream; 430 class NullStream {
431 public:
432 NullStream& stream() { return *this; }
433 };
431 434
432 // Note that g_swallow_stream is used instead of an arbitrary LOG() stream to 435 template <typename T>
433 // avoid the creation of an object with a non-trivial destructor (LogMessage). 436 inline NullStream& operator<<(NullStream& null_stream, const T&) {
434 // On MSVC x86 (checked on 2015 Update 3), this causes a few additional 437 return null_stream;
435 // pointless instructions to be emitted even at full optimization level, even 438 }
436 // though the : arm of the ternary operator is clearly never executed. Using a 439
437 // simpler object to be &'d with Voidify() avoids these extra instructions. 440 // std::endl compatibility
438 // Using a simpler POD object with a templated operator<< also works to avoid 441 inline NullStream& operator<<(NullStream& null_stream,
439 // these instructions. However, this causes warnings on statically defined 442 std::ostream& (*)(std::ostream&)) {
440 // implementations of operator<<(std::ostream, ...) in some .cc files, because 443 return null_stream;
441 // they become defined-but-unreferenced functions. A reinterpret_cast of 0 to an 444 }
442 // ostream* also is not suitable, because some compilers warn of undefined
443 // behavior.
444 #define EAT_STREAM_PARAMETERS \
445 true ? (void)0 \
446 : ::logging::LogMessageVoidify() & (*::logging::g_swallow_stream)
447 445
448 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a 446 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a
449 // boolean. 447 // boolean.
450 class CheckOpResult { 448 class CheckOpResult {
451 public: 449 public:
452 // |message| must be non-null if and only if the check failed. 450 // |message| must be non-null if and only if the check failed.
453 CheckOpResult(std::string* message) : message_(message) {} 451 CheckOpResult(std::string* message) : message_(message) {}
454 // Returns true if the check succeeded. 452 // Returns true if the check succeeded.
455 operator bool() const { return !message_; } 453 operator bool() const { return !message_; }
456 // Returns the message. 454 // Returns the message.
(...skipping 19 matching lines...) Expand all
476 474
477 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) 475 #if defined(OFFICIAL_BUILD) && defined(NDEBUG)
478 476
479 // Make all CHECK functions discard their log strings to reduce code bloat, and 477 // Make all CHECK functions discard their log strings to reduce code bloat, and
480 // improve performance, for official release builds. 478 // improve performance, for official release builds.
481 // 479 //
482 // This is not calling BreakDebugger since this is called frequently, and 480 // This is not calling BreakDebugger since this is called frequently, and
483 // calling an out-of-line function instead of a noreturn inline macro prevents 481 // calling an out-of-line function instead of a noreturn inline macro prevents
484 // compiler optimizations. 482 // compiler optimizations.
485 #define CHECK(condition) \ 483 #define CHECK(condition) \
486 UNLIKELY(!(condition)) ? IMMEDIATE_CRASH() : EAT_STREAM_PARAMETERS 484 UNLIKELY(!(condition)) \
485 ? IMMEDIATE_CRASH() \
486 : ::logging::LogMessageVoidify() & ::logging::NullStream().stream()
487 487
488 #define PCHECK(condition) CHECK(condition) 488 #define PCHECK(condition) CHECK(condition)
489 489
490 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2)) 490 #define CHECK_OP(name, op, val1, val2) CHECK((val1) op (val2))
491 491
492 #else // !(OFFICIAL_BUILD && NDEBUG) 492 #else // !(OFFICIAL_BUILD && NDEBUG)
493 493
494 #if defined(_PREFAST_) && defined(OS_WIN) 494 #if defined(_PREFAST_) && defined(OS_WIN)
495 // Use __analysis_assume to tell the VC++ static analysis engine that 495 // Use __analysis_assume to tell the VC++ static analysis engine that
496 // assert conditions are true, to suppress warnings. The LAZY_STREAM 496 // assert conditions are true, to suppress warnings. The LAZY_STREAM
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 #define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition) 657 #define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition)
658 #define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition) 658 #define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition)
659 659
660 #else // DCHECK_IS_ON() 660 #else // DCHECK_IS_ON()
661 661
662 // If !DCHECK_IS_ON(), we want to avoid emitting any references to |condition| 662 // If !DCHECK_IS_ON(), we want to avoid emitting any references to |condition|
663 // (which may reference a variable defined only if DCHECK_IS_ON()). 663 // (which may reference a variable defined only if DCHECK_IS_ON()).
664 // Contrast this with DCHECK et al., which has different behavior. 664 // Contrast this with DCHECK et al., which has different behavior.
665 665
666 #define DLOG_IS_ON(severity) false 666 #define DLOG_IS_ON(severity) false
667 #define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS 667 #define DLOG_IF(severity, condition) ::logging::NullStream().stream()
668 #define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS 668 #define DLOG_ASSERT(condition) ::logging::NullStream().stream()
669 #define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS 669 #define DPLOG_IF(severity, condition) ::logging::NullStream().stream()
670 #define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS 670 #define DVLOG_IF(verboselevel, condition) ::logging::NullStream().stream()
671 #define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS 671 #define DVPLOG_IF(verboselevel, condition) ::logging::NullStream().stream()
672 672
673 #endif // DCHECK_IS_ON() 673 #endif // DCHECK_IS_ON()
674 674
675 // DEBUG_MODE is for runtime uses like 675 // DEBUG_MODE is for runtime uses like
676 // if (DEBUG_MODE) foo.CheckThatFoo(); 676 // if (DEBUG_MODE) foo.CheckThatFoo();
677 // We tie its state to DCHECK_IS_ON(). 677 // We tie its state to DCHECK_IS_ON().
678 // 678 //
679 // For compile-time checks, #if DCHECK_IS_ON() can be used. 679 // For compile-time checks, #if DCHECK_IS_ON() can be used.
680 enum { DEBUG_MODE = DCHECK_IS_ON() }; 680 enum { DEBUG_MODE = DCHECK_IS_ON() };
681 681
682 #if DCHECK_IS_ON()
683
682 #define DLOG(severity) \ 684 #define DLOG(severity) \
683 LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) 685 LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
684 686
685 #define DPLOG(severity) \ 687 #define DPLOG(severity) \
686 LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) 688 LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
687 689
688 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 690 #define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
689 691
690 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) 692 #define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
691 693
692 // Definitions for DCHECK et al.
693
694 #if DCHECK_IS_ON()
695
696 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
697 COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__)
698 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
699 const LogSeverity LOG_DCHECK = LOG_FATAL;
700
701 #else // DCHECK_IS_ON() 694 #else // DCHECK_IS_ON()
702 695
703 // These are just dummy values. 696 #define DLOG(severity) ::logging::NullStream().stream()
704 #define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ 697 #define DPLOG(severity) ::logging::NullStream().stream()
705 COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__) 698 #define DVLOG(verboselevel) ::logging::NullStream().stream()
706 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO 699 #define DVPLOG(verboselevel) ::logging::NullStream().stream()
707 const LogSeverity LOG_DCHECK = LOG_INFO;
708 700
709 #endif // DCHECK_IS_ON() 701 #endif
702
703 // Definitions for DCHECK et al.
710 704
711 // DCHECK et al. make sure to reference |condition| regardless of 705 // DCHECK et al. make sure to reference |condition| regardless of
712 // whether DCHECKs are enabled; this is so that we don't get unused 706 // whether DCHECKs are enabled; this is so that we don't get unused
713 // variable warnings if the only use of a variable is in a DCHECK. 707 // variable warnings if the only use of a variable is in a DCHECK.
714 // This behavior is different from DLOG_IF et al. 708 // This behavior is different from DLOG_IF et al.
715 // 709 //
716 // Note that the definition of the DCHECK macros depends on whether or not 710 // Note that the definition of the DCHECK macros depends on whether or not
717 // DCHECK_IS_ON() is true. When DCHECK_IS_ON() is false, the macros use 711 // DCHECK_IS_ON() is true. When DCHECK_IS_ON() is false, the macros use
718 // EAT_STREAM_PARAMETERS to avoid expressions that would create temporaries. 712 // NullStream() to reduce the number of expressions that create temporaries,
713 // since the MSVC optimizer has trouble optimizing those temporaries away
714 // completely.
719 715
720 #if defined(_PREFAST_) && defined(OS_WIN) 716 #if defined(_PREFAST_) && defined(OS_WIN)
721 // See comments on the previous use of __analysis_assume. 717 // See comments on the previous use of __analysis_assume.
722 718
723 #define DCHECK(condition) \ 719 #define DCHECK(condition) \
724 __analysis_assume(!!(condition)), \ 720 __analysis_assume(!!(condition)), \
725 LAZY_STREAM(LOG_STREAM(DCHECK), false) \ 721 LAZY_STREAM(LOG_STREAM(DCHECK), false) \
726 << "Check failed: " #condition ". " 722 << "Check failed: " #condition ". "
727 723
728 #define DPCHECK(condition) \ 724 #define DPCHECK(condition) \
729 __analysis_assume(!!(condition)), \ 725 __analysis_assume(!!(condition)), \
730 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \ 726 LAZY_STREAM(PLOG_STREAM(DCHECK), false) \
731 << "Check failed: " #condition ". " 727 << "Check failed: " #condition ". "
732 728
733 #else // _PREFAST_ 729 #else // _PREFAST_
734 730
735 #if DCHECK_IS_ON() 731 #if DCHECK_IS_ON()
736 732
737 #define DCHECK(condition) \ 733 #define DCHECK(condition) \
738 LAZY_STREAM(LOG_STREAM(DCHECK), !(condition)) \ 734 LAZY_STREAM(LOG_STREAM(DCHECK), !(condition)) \
739 << "Check failed: " #condition ". " 735 << "Check failed: " #condition ". "
740 #define DPCHECK(condition) \ 736 #define DPCHECK(condition) \
741 LAZY_STREAM(PLOG_STREAM(DCHECK), !(condition)) \ 737 LAZY_STREAM(PLOG_STREAM(DCHECK), !(condition)) \
742 << "Check failed: " #condition ". " 738 << "Check failed: " #condition ". "
743 739
744 #else // DCHECK_IS_ON() 740 #else // DCHECK_IS_ON()
745 741
746 #define DCHECK(condition) EAT_STREAM_PARAMETERS << !(condition) 742 #define DCHECK(condition) \
747 #define DPCHECK(condition) EAT_STREAM_PARAMETERS << !(condition) 743 LAZY_STREAM(::logging::NullStream().stream(), !(condition))
744 #define DPCHECK(condition) \
745 LAZY_STREAM(::logging::NullStream().stream(), !(condition))
748 746
749 #endif // DCHECK_IS_ON() 747 #endif // DCHECK_IS_ON()
750 748
751 #endif // _PREFAST_ 749 #endif // _PREFAST_
752 750
753 // Helper macro for binary operators. 751 // Helper macro for binary operators.
754 // Don't use this macro directly in your code, use DCHECK_EQ et al below. 752 // Don't use this macro directly in your code, use DCHECK_EQ et al below.
755 // The 'switch' is used to prevent the 'else' from being ambiguous when the 753 // The 'switch' is used to prevent the 'else' from being ambiguous when the
756 // macro is used in an 'if' clause such as: 754 // macro is used in an 'if' clause such as:
757 // if (a == 1) 755 // if (a == 1)
758 // DCHECK_EQ(2, a); 756 // DCHECK_EQ(2, a);
759 #if DCHECK_IS_ON() 757 #if DCHECK_IS_ON()
760 758
761 #define DCHECK_OP(name, op, val1, val2) \ 759 #define DCHECK_OP(name, op, val1, val2) \
762 switch (0) case 0: default: \ 760 switch (0) case 0: default: \
763 if (::logging::CheckOpResult true_if_passed = \ 761 if (::logging::CheckOpResult true_if_passed = \
764 DCHECK_IS_ON() ? \ 762 DCHECK_IS_ON() ? \
765 ::logging::Check##name##Impl((val1), (val2), \ 763 ::logging::Check##name##Impl((val1), (val2), \
766 #val1 " " #op " " #val2) : nullptr) \ 764 #val1 " " #op " " #val2) : nullptr) \
767 ; \ 765 ; \
768 else \ 766 else \
769 ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \ 767 ::logging::LogMessage(__FILE__, __LINE__, ::logging::LOG_DCHECK, \
770 true_if_passed.message()).stream() 768 true_if_passed.message()).stream()
771 769
772 #else // DCHECK_IS_ON() 770 #else // DCHECK_IS_ON()
773 771
774 // When DCHECKs aren't enabled, DCHECK_OP still needs to reference operator<< 772 #define DCHECK_OP(name, op, val1, val2) \
775 // overloads for |val1| and |val2| to avoid potential compiler warnings about 773 LAZY_STREAM(::logging::NullStream().stream(), !((val1)op(val2)))
776 // unused functions. For the same reason, it also compares |val1| and |val2|
777 // using |op|.
778 //
779 // Note that the contract of DCHECK_EQ, etc is that arguments are only evaluated
780 // once. Even though |val1| and |val2| appear twice in this version of the macro
781 // expansion, this is OK, since the expression is never actually evaluated.
782 #define DCHECK_OP(name, op, val1, val2) \
783 EAT_STREAM_PARAMETERS << (::logging::MakeCheckOpValueString( \
784 ::logging::g_swallow_stream, val1), \
785 ::logging::MakeCheckOpValueString( \
786 ::logging::g_swallow_stream, val2), \
787 (val1)op(val2))
788 774
789 #endif // DCHECK_IS_ON() 775 #endif // DCHECK_IS_ON()
790 776
791 // Equality/Inequality checks - compare two values, and log a 777 // Equality/Inequality checks - compare two values, and log a
792 // LOG_DCHECK message including the two values when the result is not 778 // LOG_DCHECK message including the two values when the result is not
793 // as expected. The values must have operator<<(ostream, ...) 779 // as expected. The values must have operator<<(ostream, ...)
794 // defined. 780 // defined.
795 // 781 //
796 // You may append to the error message like so: 782 // You may append to the error message like so:
797 // DCHECK_NE(1, 2) << "The world must be ending!"; 783 // DCHECK_NE(1, 2) << "The world must be ending!";
(...skipping 16 matching lines...) Expand all
814 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) 800 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
815 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) 801 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
816 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) 802 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
817 803
818 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS) 804 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS)
819 // Implement logging of NOTREACHED() as a dedicated function to get function 805 // Implement logging of NOTREACHED() as a dedicated function to get function
820 // call overhead down to a minimum. 806 // call overhead down to a minimum.
821 void LogErrorNotReached(const char* file, int line); 807 void LogErrorNotReached(const char* file, int line);
822 #define NOTREACHED() \ 808 #define NOTREACHED() \
823 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \ 809 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \
824 : EAT_STREAM_PARAMETERS 810 : ::logging::LogMessageVoidify() & ::logging::NullStream()
825 #else 811 #else
826 #define NOTREACHED() DCHECK(false) 812 #define NOTREACHED() DCHECK(false)
827 #endif 813 #endif
828 814
829 // Redefine the standard assert to use our nice log files 815 // Redefine the standard assert to use our nice log files
830 #undef assert 816 #undef assert
831 #define assert(x) DLOG_ASSERT(x) 817 #define assert(x) DLOG_ASSERT(x)
832 818
833 // This class more or less represents a particular log message. You 819 // This class more or less represents a particular log message. You
834 // create an instance of LogMessage and then stream stuff to it. 820 // create an instance of LogMessage and then stream stuff to it.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 #endif 879 #endif
894 880
895 DISALLOW_COPY_AND_ASSIGN(LogMessage); 881 DISALLOW_COPY_AND_ASSIGN(LogMessage);
896 }; 882 };
897 883
898 // This class is used to explicitly ignore values in the conditional 884 // This class is used to explicitly ignore values in the conditional
899 // logging macros. This avoids compiler warnings like "value computed 885 // logging macros. This avoids compiler warnings like "value computed
900 // is not used" and "statement has no effect". 886 // is not used" and "statement has no effect".
901 class LogMessageVoidify { 887 class LogMessageVoidify {
902 public: 888 public:
903 LogMessageVoidify() { }
904 // This has to be an operator with a precedence lower than << but 889 // This has to be an operator with a precedence lower than << but
905 // higher than ?: 890 // higher than ?:
906 void operator&(std::ostream&) { } 891 void operator&(std::ostream&) { }
892 void operator&(NullStream&) {}
907 }; 893 };
908 894
909 #if defined(OS_WIN) 895 #if defined(OS_WIN)
910 typedef unsigned long SystemErrorCode; 896 typedef unsigned long SystemErrorCode;
911 #elif defined(OS_POSIX) 897 #elif defined(OS_POSIX)
912 typedef int SystemErrorCode; 898 typedef int SystemErrorCode;
913 #endif 899 #endif
914 900
915 // Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to 901 // Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to
916 // pull in windows.h just for GetLastError() and DWORD. 902 // pull in windows.h just for GetLastError() and DWORD.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1017
1032 #if defined(COMPILER_GCC) 1018 #if defined(COMPILER_GCC)
1033 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name 1019 // On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name
1034 // of the current function in the NOTIMPLEMENTED message. 1020 // of the current function in the NOTIMPLEMENTED message.
1035 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ 1021 #define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__
1036 #else 1022 #else
1037 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" 1023 #define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED"
1038 #endif 1024 #endif
1039 1025
1040 #if NOTIMPLEMENTED_POLICY == 0 1026 #if NOTIMPLEMENTED_POLICY == 0
1041 #define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS 1027 #define NOTIMPLEMENTED() ::logging::NullStream().stream()
1042 #elif NOTIMPLEMENTED_POLICY == 1 1028 #elif NOTIMPLEMENTED_POLICY == 1
1043 // TODO, figure out how to generate a warning 1029 // TODO, figure out how to generate a warning
1044 #define NOTIMPLEMENTED() static_assert(false, "NOT_IMPLEMENTED") 1030 #define NOTIMPLEMENTED() static_assert(false, "NOT_IMPLEMENTED")
1045 #elif NOTIMPLEMENTED_POLICY == 2 1031 #elif NOTIMPLEMENTED_POLICY == 2
1046 #define NOTIMPLEMENTED() static_assert(false, "NOT_IMPLEMENTED") 1032 #define NOTIMPLEMENTED() static_assert(false, "NOT_IMPLEMENTED")
1047 #elif NOTIMPLEMENTED_POLICY == 3 1033 #elif NOTIMPLEMENTED_POLICY == 3
1048 #define NOTIMPLEMENTED() NOTREACHED() 1034 #define NOTIMPLEMENTED() NOTREACHED()
1049 #elif NOTIMPLEMENTED_POLICY == 4 1035 #elif NOTIMPLEMENTED_POLICY == 4
1050 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG 1036 #define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
1051 #elif NOTIMPLEMENTED_POLICY == 5 1037 #elif NOTIMPLEMENTED_POLICY == 5
1052 #define NOTIMPLEMENTED() do {\ 1038 #define NOTIMPLEMENTED() \
1053 static bool logged_once = false;\ 1039 do { \
1054 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1040 static bool logged_once = false; \
1055 logged_once = true;\ 1041 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \
1056 } while(0);\ 1042 logged_once = true; \
1057 EAT_STREAM_PARAMETERS 1043 } while (0); \
1044 ::logging::NullStream().stream()
1058 #endif 1045 #endif
1059 1046
1060 #endif // BASE_LOGGING_H_ 1047 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | base/time/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698