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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // for each platform. | 440 // for each platform. |
441 #define PLOG_STREAM(severity) LOG_ERRNO_STREAM(severity) | 441 #define PLOG_STREAM(severity) LOG_ERRNO_STREAM(severity) |
442 #endif | 442 #endif |
443 | 443 |
444 #define PLOG(severity) \ | 444 #define PLOG(severity) \ |
445 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) | 445 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) |
446 | 446 |
447 #define PLOG_IF(severity, condition) \ | 447 #define PLOG_IF(severity, condition) \ |
448 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) | 448 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) |
449 | 449 |
450 #if defined(OFFICIAL_BUILD) && defined(NDEBUG) | 450 #if !defined(NDEBUG) |
| 451 // Debug builds always include DCHECK and DLOG. |
| 452 #undef LOGGING_IS_OFFICIAL_BUILD |
| 453 #define LOGGING_IS_OFFICIAL_BUILD 0 |
| 454 #elif defined(OFFICIAL_BUILD) |
| 455 // Official release builds always disable and remove DCHECK and DLOG. |
| 456 #undef LOGGING_IS_OFFICIAL_BUILD |
451 #define LOGGING_IS_OFFICIAL_BUILD 1 | 457 #define LOGGING_IS_OFFICIAL_BUILD 1 |
452 #else | 458 #elif !defined(LOGGING_IS_OFFICIAL_BUILD) |
| 459 // Unless otherwise specified, unofficial release builds include |
| 460 // DCHECK and DLOG. |
453 #define LOGGING_IS_OFFICIAL_BUILD 0 | 461 #define LOGGING_IS_OFFICIAL_BUILD 0 |
454 #endif | 462 #endif |
455 | 463 |
456 // The actual stream used isn't important. | 464 // The actual stream used isn't important. |
457 #define EAT_STREAM_PARAMETERS \ | 465 #define EAT_STREAM_PARAMETERS \ |
458 true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL) | 466 true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL) |
459 | 467 |
460 // CHECK dies with a fatal error if condition is not true. It is *not* | 468 // CHECK dies with a fatal error if condition is not true. It is *not* |
461 // controlled by NDEBUG, so the check will be executed regardless of | 469 // controlled by NDEBUG, so the check will be executed regardless of |
462 // compilation mode. | 470 // compilation mode. |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 #elif NOTIMPLEMENTED_POLICY == 5 | 991 #elif NOTIMPLEMENTED_POLICY == 5 |
984 #define NOTIMPLEMENTED() do {\ | 992 #define NOTIMPLEMENTED() do {\ |
985 static bool logged_once = false;\ | 993 static bool logged_once = false;\ |
986 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 994 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
987 logged_once = true;\ | 995 logged_once = true;\ |
988 } while(0);\ | 996 } while(0);\ |
989 EAT_STREAM_PARAMETERS | 997 EAT_STREAM_PARAMETERS |
990 #endif | 998 #endif |
991 | 999 |
992 #endif // BASE_LOGGING_H_ | 1000 #endif // BASE_LOGGING_H_ |
OLD | NEW |