| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 #define LOG_IS_ON(severity) \ | 347 #define LOG_IS_ON(severity) \ |
| 348 (::logging::ShouldCreateLogMessage(::logging::LOG_##severity)) | 348 (::logging::ShouldCreateLogMessage(::logging::LOG_##severity)) |
| 349 | 349 |
| 350 // We can't do any caching tricks with VLOG_IS_ON() like the | 350 // We can't do any caching tricks with VLOG_IS_ON() like the |
| 351 // google-glog version since it requires GCC extensions. This means | 351 // google-glog version since it requires GCC extensions. This means |
| 352 // that using the v-logging functions in conjunction with --vmodule | 352 // that using the v-logging functions in conjunction with --vmodule |
| 353 // may be slow. | 353 // may be slow. |
| 354 #define VLOG_IS_ON(verboselevel) \ | 354 #define VLOG_IS_ON(verboselevel) \ |
| 355 ((verboselevel) <= ::logging::GetVlogLevel(__FILE__)) | 355 ((verboselevel) <= ::logging::GetVlogLevel(__FILE__)) |
| 356 | 356 |
| 357 #if !defined(LIKELY) |
| 358 #if defined(COMPILER_GCC) |
| 359 #define LIKELY(x) __builtin_expect(!!(x), 1) |
| 360 #else |
| 361 #define LIKELY(x) (x) |
| 362 #endif // defined(COMPILER_GCC) |
| 363 #endif // !defined(LIKELY) |
| 364 |
| 357 // Helper macro which avoids evaluating the arguments to a stream if | 365 // Helper macro which avoids evaluating the arguments to a stream if |
| 358 // the condition doesn't hold. Condition is evaluated once and only once. | 366 // the condition doesn't hold. Condition is evaluated once and only once. |
| 359 #define LAZY_STREAM(stream, condition) \ | 367 #define LAZY_STREAM(stream, condition) \ |
| 360 !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream) | 368 LIKELY(!(condition)) ? (void) 0 : ::logging::LogMessageVoidify() & (stream) |
| 361 | 369 |
| 362 // We use the preprocessor's merging operator, "##", so that, e.g., | 370 // We use the preprocessor's merging operator, "##", so that, e.g., |
| 363 // LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny | 371 // LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny |
| 364 // subtle difference between ostream member streaming functions (e.g., | 372 // subtle difference between ostream member streaming functions (e.g., |
| 365 // ostream::operator<<(int) and ostream non-member streaming functions | 373 // ostream::operator<<(int) and ostream non-member streaming functions |
| 366 // (e.g., ::operator<<(ostream&, string&): it turns out that it's | 374 // (e.g., ::operator<<(ostream&, string&): it turns out that it's |
| 367 // impossible to stream something like a string directly to an unnamed | 375 // impossible to stream something like a string directly to an unnamed |
| 368 // ostream. We employ a neat hack by calling the stream() member | 376 // ostream. We employ a neat hack by calling the stream() member |
| 369 // function of LogMessage which seems to avoid the problem. | 377 // function of LogMessage which seems to avoid the problem. |
| 370 #define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream() | 378 #define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream() |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 #elif NOTIMPLEMENTED_POLICY == 5 | 964 #elif NOTIMPLEMENTED_POLICY == 5 |
| 957 #define NOTIMPLEMENTED() do {\ | 965 #define NOTIMPLEMENTED() do {\ |
| 958 static bool logged_once = false;\ | 966 static bool logged_once = false;\ |
| 959 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 967 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 960 logged_once = true;\ | 968 logged_once = true;\ |
| 961 } while(0);\ | 969 } while(0);\ |
| 962 EAT_STREAM_PARAMETERS | 970 EAT_STREAM_PARAMETERS |
| 963 #endif | 971 #endif |
| 964 | 972 |
| 965 #endif // BASE_LOGGING_H_ | 973 #endif // BASE_LOGGING_H_ |
| OLD | NEW |