Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <cassert> | 8 #include <cassert> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO | 611 #define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO |
| 612 const LogSeverity LOG_DCHECK = LOG_INFO; | 612 const LogSeverity LOG_DCHECK = LOG_INFO; |
| 613 | 613 |
| 614 #endif // DCHECK_IS_ON | 614 #endif // DCHECK_IS_ON |
| 615 | 615 |
| 616 // DCHECK et al. make sure to reference |condition| regardless of | 616 // DCHECK et al. make sure to reference |condition| regardless of |
| 617 // whether DCHECKs are enabled; this is so that we don't get unused | 617 // whether DCHECKs are enabled; this is so that we don't get unused |
| 618 // variable warnings if the only use of a variable is in a DCHECK. | 618 // variable warnings if the only use of a variable is in a DCHECK. |
| 619 // This behavior is different from DLOG_IF et al. | 619 // This behavior is different from DLOG_IF et al. |
| 620 | 620 |
| 621 #define DCHECK(condition) \ | 621 #define DCHECK(condition) \ |
| 622 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ | 622 LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON ? !(condition) : false) \ |
|
Peter Kasting
2014/09/23 23:07:34
This form of the macro eliminates "unused variable
| |
| 623 << "Check failed: " #condition ". " | 623 << "Check failed: " #condition ". " |
| 624 | 624 |
| 625 #define DPCHECK(condition) \ | 625 #define DPCHECK(condition) \ |
| 626 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON && !(condition)) \ | 626 LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON ? !(condition) : false) \ |
| 627 << "Check failed: " #condition ". " | 627 << "Check failed: " #condition ". " |
| 628 | 628 |
| 629 // Helper macro for binary operators. | 629 // Helper macro for binary operators. |
| 630 // Don't use this macro directly in your code, use DCHECK_EQ et al below. | 630 // Don't use this macro directly in your code, use DCHECK_EQ et al below. |
| 631 #define DCHECK_OP(name, op, val1, val2) \ | 631 #define DCHECK_OP(name, op, val1, val2) \ |
| 632 if (DCHECK_IS_ON) \ | 632 if (DCHECK_IS_ON) \ |
| 633 if (std::string* _result = \ | 633 if (std::string* _result = \ |
| 634 logging::Check##name##Impl((val1), (val2), \ | 634 logging::Check##name##Impl((val1), (val2), \ |
| 635 #val1 " " #op " " #val2)) \ | 635 #val1 " " #op " " #val2)) \ |
| 636 logging::LogMessage( \ | 636 logging::LogMessage( \ |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 #elif NOTIMPLEMENTED_POLICY == 5 | 890 #elif NOTIMPLEMENTED_POLICY == 5 |
| 891 #define NOTIMPLEMENTED() do {\ | 891 #define NOTIMPLEMENTED() do {\ |
| 892 static bool logged_once = false;\ | 892 static bool logged_once = false;\ |
| 893 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 893 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 894 logged_once = true;\ | 894 logged_once = true;\ |
| 895 } while(0);\ | 895 } while(0);\ |
| 896 EAT_STREAM_PARAMETERS | 896 EAT_STREAM_PARAMETERS |
| 897 #endif | 897 #endif |
| 898 | 898 |
| 899 #endif // BASE_LOGGING_H_ | 899 #endif // BASE_LOGGING_H_ |
| OLD | NEW |