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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 ((::logging::LOG_ ## severity) >= ::logging::GetMinLogLevel()) | 343 ((::logging::LOG_ ## severity) >= ::logging::GetMinLogLevel()) |
344 | 344 |
345 // We can't do any caching tricks with VLOG_IS_ON() like the | 345 // We can't do any caching tricks with VLOG_IS_ON() like the |
346 // google-glog version since it requires GCC extensions. This means | 346 // google-glog version since it requires GCC extensions. This means |
347 // that using the v-logging functions in conjunction with --vmodule | 347 // that using the v-logging functions in conjunction with --vmodule |
348 // may be slow. | 348 // may be slow. |
349 #define VLOG_IS_ON(verboselevel) \ | 349 #define VLOG_IS_ON(verboselevel) \ |
350 ((verboselevel) <= ::logging::GetVlogLevel(__FILE__)) | 350 ((verboselevel) <= ::logging::GetVlogLevel(__FILE__)) |
351 | 351 |
352 // Helper macro which avoids evaluating the arguments to a stream if | 352 // Helper macro which avoids evaluating the arguments to a stream if |
353 // the condition doesn't hold. | 353 // the condition doesn't hold. Condition is evaluated once and only once. |
354 #define LAZY_STREAM(stream, condition) \ | 354 #define LAZY_STREAM(stream, condition) \ |
355 !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream) | 355 !(condition) ? (void) 0 : ::logging::LogMessageVoidify() & (stream) |
356 | 356 |
357 // We use the preprocessor's merging operator, "##", so that, e.g., | 357 // We use the preprocessor's merging operator, "##", so that, e.g., |
358 // LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny | 358 // LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny |
359 // subtle difference between ostream member streaming functions (e.g., | 359 // subtle difference between ostream member streaming functions (e.g., |
360 // ostream::operator<<(int) and ostream non-member streaming functions | 360 // ostream::operator<<(int) and ostream non-member streaming functions |
361 // (e.g., ::operator<<(ostream&, string&): it turns out that it's | 361 // (e.g., ::operator<<(ostream&, string&): it turns out that it's |
362 // impossible to stream something like a string directly to an unnamed | 362 // impossible to stream something like a string directly to an unnamed |
363 // ostream. We employ a neat hack by calling the stream() member | 363 // ostream. We employ a neat hack by calling the stream() member |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 #elif NOTIMPLEMENTED_POLICY == 5 | 926 #elif NOTIMPLEMENTED_POLICY == 5 |
927 #define NOTIMPLEMENTED() do {\ | 927 #define NOTIMPLEMENTED() do {\ |
928 static bool logged_once = false;\ | 928 static bool logged_once = false;\ |
929 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 929 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
930 logged_once = true;\ | 930 logged_once = true;\ |
931 } while(0);\ | 931 } while(0);\ |
932 EAT_STREAM_PARAMETERS | 932 EAT_STREAM_PARAMETERS |
933 #endif | 933 #endif |
934 | 934 |
935 #endif // BASE_LOGGING_H_ | 935 #endif // BASE_LOGGING_H_ |
OLD | NEW |