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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cassert> | 10 #include <cassert> |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ | 419 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ |
| 420 ::logging::GetLastSystemErrorCode()).stream() | 420 ::logging::GetLastSystemErrorCode()).stream() |
| 421 #endif | 421 #endif |
| 422 | 422 |
| 423 #define PLOG(severity) \ | 423 #define PLOG(severity) \ |
| 424 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) | 424 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) |
| 425 | 425 |
| 426 #define PLOG_IF(severity, condition) \ | 426 #define PLOG_IF(severity, condition) \ |
| 427 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) | 427 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) |
| 428 | 428 |
| 429 // The actual stream used isn't important. | 429 extern std::ostream* g_swallow_stream; |
| 430 #define EAT_STREAM_PARAMETERS \ | 430 |
| 431 true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL) | 431 #define EAT_STREAM_PARAMETERS \ |
|
dcheng
2016/12/09 23:16:48
Can we add a comment that mentions the subtleties
scottmg
2016/12/09 23:30:26
Sure. Are you concerned about not actually assigni
| |
| 432 true ? (void)0 \ | |
| 433 : ::logging::LogMessageVoidify() & (*::logging::g_swallow_stream) | |
| 432 | 434 |
| 433 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a | 435 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a |
| 434 // boolean. | 436 // boolean. |
| 435 class CheckOpResult { | 437 class CheckOpResult { |
| 436 public: | 438 public: |
| 437 // |message| must be non-null if and only if the check failed. | 439 // |message| must be non-null if and only if the check failed. |
| 438 CheckOpResult(std::string* message) : message_(message) {} | 440 CheckOpResult(std::string* message) : message_(message) {} |
| 439 // Returns true if the check succeeded. | 441 // Returns true if the check succeeded. |
| 440 operator bool() const { return !message_; } | 442 operator bool() const { return !message_; } |
| 441 // Returns the message. | 443 // Returns the message. |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 #elif NOTIMPLEMENTED_POLICY == 5 | 1017 #elif NOTIMPLEMENTED_POLICY == 5 |
| 1016 #define NOTIMPLEMENTED() do {\ | 1018 #define NOTIMPLEMENTED() do {\ |
| 1017 static bool logged_once = false;\ | 1019 static bool logged_once = false;\ |
| 1018 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1020 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 1019 logged_once = true;\ | 1021 logged_once = true;\ |
| 1020 } while(0);\ | 1022 } while(0);\ |
| 1021 EAT_STREAM_PARAMETERS | 1023 EAT_STREAM_PARAMETERS |
| 1022 #endif | 1024 #endif |
| 1023 | 1025 |
| 1024 #endif // BASE_LOGGING_H_ | 1026 #endif // BASE_LOGGING_H_ |
| OLD | NEW |