| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "base/logging.h" | 36 #include "base/logging.h" |
| 37 #include "platform/wtf/Compiler.h" | 37 #include "platform/wtf/Compiler.h" |
| 38 #include "platform/wtf/Noncopyable.h" | 38 #include "platform/wtf/Noncopyable.h" |
| 39 #include "platform/wtf/WTFExport.h" | 39 #include "platform/wtf/WTFExport.h" |
| 40 #include "platform/wtf/build_config.h" | 40 #include "platform/wtf/build_config.h" |
| 41 | 41 |
| 42 #if OS(WIN) | 42 #if OS(WIN) |
| 43 #include <windows.h> | 43 #include <windows.h> |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #ifndef LOG_DISABLED | |
| 47 #define LOG_DISABLED !DCHECK_IS_ON() | |
| 48 #endif | |
| 49 | |
| 50 // WTFLogAlways() is deprecated. crbug.com/638849 | 46 // WTFLogAlways() is deprecated. crbug.com/638849 |
| 51 WTF_EXPORT PRINTF_FORMAT(1, 2) // NOLINT | 47 WTF_EXPORT PRINTF_FORMAT(1, 2) // NOLINT |
| 52 void WTFLogAlways(const char* format, ...); | 48 void WTFLogAlways(const char* format, ...); |
| 53 | 49 |
| 54 namespace WTF { | 50 namespace WTF { |
| 55 | 51 |
| 56 #if LOG_DISABLED | 52 #if !DCHECK_IS_ON() |
| 57 | 53 |
| 58 #define WTF_CREATE_SCOPED_LOGGER(...) ((void)0) | 54 #define WTF_CREATE_SCOPED_LOGGER(...) ((void)0) |
| 59 #define WTF_CREATE_SCOPED_LOGGER_IF(...) ((void)0) | 55 #define WTF_CREATE_SCOPED_LOGGER_IF(...) ((void)0) |
| 60 #define WTF_APPEND_SCOPED_LOGGER(...) ((void)0) | 56 #define WTF_APPEND_SCOPED_LOGGER(...) ((void)0) |
| 61 | 57 |
| 62 #else | 58 #else |
| 63 | 59 |
| 64 // ScopedLogger wraps log messages in parentheses, with indentation proportional | 60 // ScopedLogger wraps log messages in parentheses, with indentation proportional |
| 65 // to the number of instances. This makes it easy to see the flow of control in | 61 // to the number of instances. This makes it easy to see the flow of control in |
| 66 // the output, particularly when instrumenting recursive functions. | 62 // the output, particularly when instrumenting recursive functions. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // entry. | 94 // entry. |
| 99 static PrintFunctionPtr print_func_; | 95 static PrintFunctionPtr print_func_; |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 #define WTF_CREATE_SCOPED_LOGGER(name, ...) \ | 98 #define WTF_CREATE_SCOPED_LOGGER(name, ...) \ |
| 103 WTF::ScopedLogger name(true, __VA_ARGS__) | 99 WTF::ScopedLogger name(true, __VA_ARGS__) |
| 104 #define WTF_CREATE_SCOPED_LOGGER_IF(name, condition, ...) \ | 100 #define WTF_CREATE_SCOPED_LOGGER_IF(name, condition, ...) \ |
| 105 WTF::ScopedLogger name(condition, __VA_ARGS__) | 101 WTF::ScopedLogger name(condition, __VA_ARGS__) |
| 106 #define WTF_APPEND_SCOPED_LOGGER(name, ...) (name.Log(__VA_ARGS__)) | 102 #define WTF_APPEND_SCOPED_LOGGER(name, ...) (name.Log(__VA_ARGS__)) |
| 107 | 103 |
| 108 #endif // LOG_DISABLED | 104 #endif // !DCHECK_IS_ON() |
| 109 | 105 |
| 110 } // namespace WTF | 106 } // namespace WTF |
| 111 | 107 |
| 112 #define DCHECK_AT(assertion, file, line) \ | 108 #define DCHECK_AT(assertion, file, line) \ |
| 113 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ | 109 LAZY_STREAM(logging::LogMessage(file, line, #assertion).stream(), \ |
| 114 DCHECK_IS_ON() ? !(assertion) : false) | 110 DCHECK_IS_ON() ? !(assertion) : false) |
| 115 | 111 |
| 116 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 112 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 117 // that code testing this macro has included this header. | 113 // that code testing this macro has included this header. |
| 118 #if defined(ADDRESS_SANITIZER) || DCHECK_IS_ON() | 114 #if defined(ADDRESS_SANITIZER) || DCHECK_IS_ON() |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } \ | 206 } \ |
| 211 void To##thisType##OrDie(const thisType*); \ | 207 void To##thisType##OrDie(const thisType*); \ |
| 212 void To##thisType##OrDie(const thisType&) | 208 void To##thisType##OrDie(const thisType&) |
| 213 | 209 |
| 214 // Check at compile time that related enums stay in sync. | 210 // Check at compile time that related enums stay in sync. |
| 215 #define STATIC_ASSERT_ENUM(a, b) \ | 211 #define STATIC_ASSERT_ENUM(a, b) \ |
| 216 static_assert(static_cast<int>(a) == static_cast<int>(b), \ | 212 static_assert(static_cast<int>(a) == static_cast<int>(b), \ |
| 217 "mismatching enum: " #a) | 213 "mismatching enum: " #a) |
| 218 | 214 |
| 219 #endif // WTF_Assertions_h | 215 #endif // WTF_Assertions_h |
| OLD | NEW |