OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 // There are several variations on the LOG macro which facilitate logging | 29 // There are several variations on the LOG macro which facilitate logging |
30 // of common error conditions, detailed below. | 30 // of common error conditions, detailed below. |
31 | 31 |
32 // LOG(sev) logs the given stream at severity "sev", which must be a | 32 // LOG(sev) logs the given stream at severity "sev", which must be a |
33 // compile-time constant of the LoggingSeverity type, without the namespace | 33 // compile-time constant of the LoggingSeverity type, without the namespace |
34 // prefix. | 34 // prefix. |
35 // LOG_V(sev) Like LOG(), but sev is a run-time variable of the LoggingSeverity | 35 // LOG_V(sev) Like LOG(), but sev is a run-time variable of the LoggingSeverity |
36 // type (basically, it just doesn't prepend the namespace). | 36 // type (basically, it just doesn't prepend the namespace). |
37 // LOG_F(sev) Like LOG(), but includes the name of the current function. | 37 // LOG_F(sev) Like LOG(), but includes the name of the current function. |
38 | 38 |
39 // Additional helper macros added by WebRTC: | |
40 // LOG_API is a shortcut for API call logging. Pass in the input parameters of | |
41 // the method. For example: | |
42 // Foo(int bar, int baz) { | |
43 // LOG_API2(bar, baz); | |
44 // } | |
45 // | |
46 // LOG_FERR is a shortcut for logging a failed function call. For example: | |
47 // if (!Foo(bar)) { | |
48 // LOG_FERR1(LS_WARNING, Foo, bar); | |
49 // } | |
50 | |
51 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ | 39 #ifndef WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ |
52 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ | 40 #define WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ |
53 | 41 |
54 #include <sstream> | 42 #include <sstream> |
55 | 43 |
56 namespace webrtc { | 44 namespace webrtc { |
57 | 45 |
58 ////////////////////////////////////////////////////////////////////// | 46 ////////////////////////////////////////////////////////////////////// |
59 | 47 |
60 // Note that the non-standard LoggingSeverity aliases exist because they are | 48 // Note that the non-standard LoggingSeverity aliases exist because they are |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 LOG_SEVERITY_PRECONDITION(sev) \ | 118 LOG_SEVERITY_PRECONDITION(sev) \ |
131 webrtc::LogMessage(__FILE__, __LINE__, sev).stream() | 119 webrtc::LogMessage(__FILE__, __LINE__, sev).stream() |
132 | 120 |
133 // The _F version prefixes the message with the current function name. | 121 // The _F version prefixes the message with the current function name. |
134 #if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F) | 122 #if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F) |
135 #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": " | 123 #define LOG_F(sev) LOG(sev) << __PRETTY_FUNCTION__ << ": " |
136 #else | 124 #else |
137 #define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " | 125 #define LOG_F(sev) LOG(sev) << __FUNCTION__ << ": " |
138 #endif | 126 #endif |
139 | 127 |
140 #define LOG_API0() LOG_F(LS_VERBOSE) | |
141 #define LOG_API1(v1) LOG_API0() << #v1 << "=" << v1 | |
142 #define LOG_API2(v1, v2) LOG_API1(v1) \ | |
143 << ", " << #v2 << "=" << v2 | |
144 #define LOG_API3(v1, v2, v3) LOG_API2(v1, v2) \ | |
145 << ", " << #v3 << "=" << v3 | |
146 | |
147 #define LOG_FERR0(sev, func) LOG(sev) << #func << " failed" | |
148 #define LOG_FERR1(sev, func, v1) LOG_FERR0(sev, func) \ | |
149 << ": " << #v1 << "=" << v1 | |
150 #define LOG_FERR2(sev, func, v1, v2) LOG_FERR1(sev, func, v1) \ | |
151 << ", " << #v2 << "=" << v2 | |
152 #define LOG_FERR3(sev, func, v1, v2, v3) LOG_FERR2(sev, func, v1, v2) \ | |
153 << ", " << #v3 << "=" << v3 | |
154 #define LOG_FERR4(sev, func, v1, v2, v3, v4) LOG_FERR3(sev, func, v1, v2, v3) \ | |
155 << ", " << #v4 << "=" << v4 | |
156 | |
157 #endif // LOG | 128 #endif // LOG |
158 | 129 |
159 } // namespace webrtc | 130 } // namespace webrtc |
160 | 131 |
161 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ | 132 #endif // WEBRTC_SYSTEM_WRAPPERS_INCLUDE_LOGGING_H_ |
OLD | NEW |