OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file overrides the logging macros in WebRTC (webrtc/base/logging.h). |
| 6 // Instead of using WebRTC's logging implementation, the WebRTC macros are |
| 7 // mapped to DIAGNOSTIC_LOGING. In it's implementation (DiagnosticLogMessage in |
| 8 // third_party/webrtc_overrides/webrtc/base/logging.h), the corresponding |
| 9 // base/logging.h macros (e.g. Chromium's VLOG) are used. |
| 10 // If this file is included outside of WebRTC/libjingle it should be included |
| 11 // after base/logging.h (if any) or compiler error or unexpected behavior may |
| 12 // occur (macros that have the same name in WebRTC as in Chromium will use |
| 13 // the WebRTC definition if this file is included first). |
| 14 |
| 15 // Setting the LoggingSeverity (and lower) that should be written to file should |
| 16 // be done via command line by specifying the flags: |
| 17 // --vmodule or --v please see base/logging.h for details on how to use them. |
| 18 // Specifying what file to write to is done using InitLogging also in |
| 19 // base/logging.h. |
| 20 |
| 21 // The macros and classes declared in here are not described as they are |
| 22 // NOT TO BE USED outside of WebRTC/libjingle. |
| 23 |
| 24 #ifndef THIRD_PARTY_WEBRTC_OVERRIDES_WEBRTC_BASE_LOGGING_H_ |
| 25 #define THIRD_PARTY_WEBRTC_OVERRIDES_WEBRTC_BASE_LOGGING_H_ |
| 26 |
| 27 #include "third_party/webrtc_overrides/webrtc/base/diagnostic_logging.h" |
| 28 |
| 29 ////////////////////////////////////////////////////////////////////// |
| 30 // WebRTC macros which in DiagnosticLogMessage are mapped over to |
| 31 // their VLOG equivalent in base/logging.h. |
| 32 ////////////////////////////////////////////////////////////////////// |
| 33 |
| 34 #if defined(LOGGING_INSIDE_WEBRTC) |
| 35 |
| 36 namespace rtc { |
| 37 |
| 38 // Note that |N| is the size *with* the null terminator. |
| 39 bool CheckVlogIsOnHelper(LoggingSeverity severity, |
| 40 const char* file, size_t N); |
| 41 |
| 42 template <size_t N> |
| 43 bool CheckVlogIsOn(LoggingSeverity severity, const char (&file)[N]) { |
| 44 return CheckVlogIsOnHelper(severity, file, N); |
| 45 } |
| 46 |
| 47 } // namespace rtc |
| 48 |
| 49 #define DIAGNOSTIC_LOG(sev, ctx, err, ...) \ |
| 50 rtc::DiagnosticLogMessage( \ |
| 51 __FILE__, __LINE__, sev, rtc::ERRCTX_ ## ctx, err, ##__VA_ARGS__).stream() |
| 52 |
| 53 #define LOG_CHECK_LEVEL(sev) CheckVlogIsOn(rtc::sev, __FILE__) |
| 54 #define LOG_CHECK_LEVEL_V(sev) CheckVlogIsOn(sev, __FILE__) |
| 55 |
| 56 #define LOG_V(sev) DIAGNOSTIC_LOG(sev, NONE, 0) |
| 57 #undef LOG |
| 58 #define LOG(sev) DIAGNOSTIC_LOG(rtc::sev, NONE, 0) |
| 59 |
| 60 // The _F version prefixes the message with the current function name. |
| 61 #if defined(__GNUC__) && defined(_DEBUG) |
| 62 #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": " |
| 63 #else |
| 64 #define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " |
| 65 #endif |
| 66 |
| 67 #define LOG_E(sev, ctx, err, ...) \ |
| 68 DIAGNOSTIC_LOG(rtc::sev, ctx, err, ##__VA_ARGS__) |
| 69 |
| 70 #undef LOG_ERRNO_EX |
| 71 #define LOG_ERRNO_EX(sev, err) LOG_E(sev, ERRNO, err) |
| 72 #undef LOG_ERRNO |
| 73 #define LOG_ERRNO(sev) LOG_ERRNO_EX(sev, errno) |
| 74 |
| 75 #if defined(WEBRTC_WIN) |
| 76 #define LOG_GLE_EX(sev, err) LOG_E(sev, HRESULT, err) |
| 77 #define LOG_GLE(sev) LOG_GLE_EX(sev, GetLastError()) |
| 78 #define LOG_GLEM(sev, mod) LOG_E(sev, HRESULT, GetLastError(), mod) |
| 79 #define LOG_ERR_EX(sev, err) LOG_GLE_EX(sev, err) |
| 80 #define LOG_ERR(sev) LOG_GLE(sev) |
| 81 #define LAST_SYSTEM_ERROR (::GetLastError()) |
| 82 #else |
| 83 #define LOG_ERR_EX(sev, err) LOG_ERRNO_EX(sev, err) |
| 84 #define LOG_ERR(sev) LOG_ERRNO(sev) |
| 85 #define LAST_SYSTEM_ERROR (errno) |
| 86 #endif // OS_WIN |
| 87 |
| 88 #undef PLOG |
| 89 #define PLOG(sev, err) LOG_ERR_EX(sev, err) |
| 90 |
| 91 #endif // LOGGING_INSIDE_WEBRTC |
| 92 |
| 93 #endif // THIRD_PARTY_WEBRTC_OVERRIDES_WEBRTC_BASE_LOGGING_H_ |
OLD | NEW |