OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // | 73 // |
74 // int err = LibraryFunc(); | 74 // int err = LibraryFunc(); |
75 // LOG(LS_ERROR) << "LibraryFunc returned: " | 75 // LOG(LS_ERROR) << "LibraryFunc returned: " |
76 // << ErrorName(err, LIBRARY_ERRORS); | 76 // << ErrorName(err, LIBRARY_ERRORS); |
77 | 77 |
78 struct ConstantLabel { int value; const char * label; }; | 78 struct ConstantLabel { int value; const char * label; }; |
79 #define KLABEL(x) { x, #x } | 79 #define KLABEL(x) { x, #x } |
80 #define TLABEL(x, y) { x, y } | 80 #define TLABEL(x, y) { x, y } |
81 #define LASTLABEL { 0, 0 } | 81 #define LASTLABEL { 0, 0 } |
82 | 82 |
83 const char * FindLabel(int value, const ConstantLabel entries[]); | 83 const char* FindLabel(int value, const ConstantLabel entries[]); |
84 std::string ErrorName(int err, const ConstantLabel* err_table); | 84 std::string ErrorName(int err, const ConstantLabel* err_table); |
85 | 85 |
86 ////////////////////////////////////////////////////////////////////// | 86 ////////////////////////////////////////////////////////////////////// |
87 | 87 |
88 // Note that the non-standard LoggingSeverity aliases exist because they are | 88 // Note that the non-standard LoggingSeverity aliases exist because they are |
89 // still in broad use. The meanings of the levels are: | 89 // still in broad use. The meanings of the levels are: |
90 // LS_SENSITIVE: Information which should only be logged with the consent | 90 // LS_SENSITIVE: Information which should only be logged with the consent |
91 // of the user, due to privacy concerns. | 91 // of the user, due to privacy concerns. |
92 // LS_VERBOSE: This level is for data which we do not want to appear in the | 92 // LS_VERBOSE: This level is for data which we do not want to appear in the |
93 // normal debug log, but should appear in diagnostic logs. | 93 // normal debug log, but should appear in diagnostic logs. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 static void LogThreads(bool on = true); | 156 static void LogThreads(bool on = true); |
157 | 157 |
158 // LogTimestamps: Display the elapsed time of the program | 158 // LogTimestamps: Display the elapsed time of the program |
159 static void LogTimestamps(bool on = true); | 159 static void LogTimestamps(bool on = true); |
160 | 160 |
161 // These are the available logging channels | 161 // These are the available logging channels |
162 // Debug: Debug console on Windows, otherwise stderr | 162 // Debug: Debug console on Windows, otherwise stderr |
163 static void LogToDebug(LoggingSeverity min_sev); | 163 static void LogToDebug(LoggingSeverity min_sev); |
164 static LoggingSeverity GetLogToDebug() { return dbg_sev_; } | 164 static LoggingSeverity GetLogToDebug() { return dbg_sev_; } |
165 | 165 |
| 166 // Sets whether logs will be directed to stderr in debug mode. |
| 167 static void SetLogToStderr(bool log_to_stderr); |
| 168 |
166 // Stream: Any non-blocking stream interface. LogMessage takes ownership of | 169 // Stream: Any non-blocking stream interface. LogMessage takes ownership of |
167 // the stream. Multiple streams may be specified by using AddLogToStream. | 170 // the stream. Multiple streams may be specified by using AddLogToStream. |
168 // LogToStream is retained for backwards compatibility; when invoked, it | 171 // LogToStream is retained for backwards compatibility; when invoked, it |
169 // will discard any previously set streams and install the specified stream. | 172 // will discard any previously set streams and install the specified stream. |
170 // GetLogToStream gets the severity for the specified stream, of if none | 173 // GetLogToStream gets the severity for the specified stream, of if none |
171 // is specified, the minimum stream severity. | 174 // is specified, the minimum stream severity. |
172 // RemoveLogToStream removes the specified stream, without destroying it. | 175 // RemoveLogToStream removes the specified stream, without destroying it. |
173 static int GetLogToStream(LogSink* stream = NULL); | 176 static int GetLogToStream(LogSink* stream = NULL); |
174 static void AddLogToStream(LogSink* stream, LoggingSeverity min_sev); | 177 static void AddLogToStream(LogSink* stream, LoggingSeverity min_sev); |
175 static void RemoveLogToStream(LogSink* stream); | 178 static void RemoveLogToStream(LogSink* stream); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // be logged. | 218 // be logged. |
216 // ctx_sev_ is the minimum level at which file context is displayed | 219 // ctx_sev_ is the minimum level at which file context is displayed |
217 static LoggingSeverity min_sev_, dbg_sev_, ctx_sev_; | 220 static LoggingSeverity min_sev_, dbg_sev_, ctx_sev_; |
218 | 221 |
219 // The output streams and their associated severities | 222 // The output streams and their associated severities |
220 static StreamList streams_; | 223 static StreamList streams_; |
221 | 224 |
222 // Flags for formatting options | 225 // Flags for formatting options |
223 static bool thread_, timestamp_; | 226 static bool thread_, timestamp_; |
224 | 227 |
| 228 // Determines if logs will be directed to stderr in debug mode. |
| 229 static bool log_to_stderr_; |
| 230 |
225 DISALLOW_COPY_AND_ASSIGN(LogMessage); | 231 DISALLOW_COPY_AND_ASSIGN(LogMessage); |
226 }; | 232 }; |
227 | 233 |
228 ////////////////////////////////////////////////////////////////////// | 234 ////////////////////////////////////////////////////////////////////// |
229 // Logging Helpers | 235 // Logging Helpers |
230 ////////////////////////////////////////////////////////////////////// | 236 ////////////////////////////////////////////////////////////////////// |
231 | 237 |
232 class LogMultilineState { | 238 class LogMultilineState { |
233 public: | 239 public: |
234 size_t unprintable_count_[2]; | 240 size_t unprintable_count_[2]; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 #define PLOG(sev, err) \ | 344 #define PLOG(sev, err) \ |
339 LOG_ERR_EX(sev, err) | 345 LOG_ERR_EX(sev, err) |
340 | 346 |
341 // TODO(?): Add an "assert" wrapper that logs in the same manner. | 347 // TODO(?): Add an "assert" wrapper that logs in the same manner. |
342 | 348 |
343 #endif // LOG | 349 #endif // LOG |
344 | 350 |
345 } // namespace rtc | 351 } // namespace rtc |
346 | 352 |
347 #endif // WEBRTC_BASE_LOGGING_H_ | 353 #endif // WEBRTC_BASE_LOGGING_H_ |
OLD | NEW |