Index: base/logging.h |
=================================================================== |
--- base/logging.h (revision 6392) |
+++ base/logging.h (working copy) |
@@ -258,7 +258,64 @@ |
// foo.CheckThatFoo(); |
// #endif |
+#ifdef OFFICIAL_BUILD |
+// We want to have optimized code for an official build so we remove DLOGS and |
+// DCHECK from the executable. |
+ |
+#define DLOG(severity) \ |
+ true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity) |
+ |
+#define DLOG_IF(severity, condition) \ |
+ true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity) |
+ |
+#define DLOG_ASSERT(condition) \ |
+ true ? (void) 0 : LOG_ASSERT(condition) |
+ |
+enum { DEBUG_MODE = 0 }; |
+ |
+// This macro can be followed by a sequence of stream parameters in |
+// non-debug mode. The DCHECK and friends macros use this so that |
+// the expanded expression DCHECK(foo) << "asdf" is still syntactically |
+// valid, even though the expression will get optimized away. |
+#define NDEBUG_EAT_STREAM_PARAMETERS \ |
+ logging::LogMessage(__FILE__, __LINE__).stream() |
+ |
+#define DCHECK(condition) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_EQ(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_NE(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_LE(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_LT(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_GE(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_GT(val1, val2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_STREQ(str1, str2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_STRCASEEQ(str1, str2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_STRNE(str1, str2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#define DCHECK_STRCASENE(str1, str2) \ |
+ while (false) NDEBUG_EAT_STREAM_PARAMETERS |
+ |
+#else // OFFICIAL_BUILD |
Nicolas Sylvain
2008/12/06 15:29:50
The comment here is confusing, maybe we should jus
|
#ifndef NDEBUG |
+// On a regular debug build, we want to have DCHECKS and DLOGS enabled. |
#define DLOG(severity) LOG(severity) |
#define DLOG_IF(severity, condition) LOG_IF(severity, condition) |
@@ -312,7 +369,8 @@ |
#define DCHECK_BOUND(B,A) DCHECK(B <= (sizeof(A)/sizeof(A[0]))) |
#else // NDEBUG |
- |
+// On a regular release build we want to be able to enable DCHECKS through the |
+// command line. |
#define DLOG(severity) \ |
true ? (void) 0 : logging::LogMessageVoidify() & LOG(severity) |
@@ -407,6 +465,7 @@ |
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) |
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) |
+#endif // OFFICIAL_BUILD |
#define NOTREACHED() DCHECK(false) |
@@ -541,4 +600,3 @@ |
#endif |
#endif // BASE_LOGGING_H_ |
- |