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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Virtual sink interface that can receive log messages. | 124 // Virtual sink interface that can receive log messages. |
125 class LogSink { | 125 class LogSink { |
126 public: | 126 public: |
127 LogSink() {} | 127 LogSink() {} |
128 virtual ~LogSink() {} | 128 virtual ~LogSink() {} |
129 virtual void OnLogMessage(const std::string& message) = 0; | 129 virtual void OnLogMessage(const std::string& message) = 0; |
130 }; | 130 }; |
131 | 131 |
132 class LogMessage { | 132 class LogMessage { |
133 public: | 133 public: |
134 static const uint32 WARN_SLOW_LOGS_DELAY = 50; // ms | 134 static const uint32_t WARN_SLOW_LOGS_DELAY = 50; // ms |
135 | 135 |
136 LogMessage(const char* file, int line, LoggingSeverity sev, | 136 LogMessage(const char* file, int line, LoggingSeverity sev, |
137 LogErrorContext err_ctx = ERRCTX_NONE, int err = 0, | 137 LogErrorContext err_ctx = ERRCTX_NONE, int err = 0, |
138 const char* module = NULL); | 138 const char* module = NULL); |
139 | 139 |
140 LogMessage(const char* file, | 140 LogMessage(const char* file, |
141 int line, | 141 int line, |
142 LoggingSeverity sev, | 142 LoggingSeverity sev, |
143 const std::string& tag); | 143 const std::string& tag); |
144 | 144 |
145 ~LogMessage(); | 145 ~LogMessage(); |
146 | 146 |
147 static inline bool Loggable(LoggingSeverity sev) { return (sev >= min_sev_); } | 147 static inline bool Loggable(LoggingSeverity sev) { return (sev >= min_sev_); } |
148 std::ostream& stream() { return print_stream_; } | 148 std::ostream& stream() { return print_stream_; } |
149 | 149 |
150 // Returns the time at which this function was called for the first time. | 150 // Returns the time at which this function was called for the first time. |
151 // The time will be used as the logging start time. | 151 // The time will be used as the logging start time. |
152 // If this is not called externally, the LogMessage ctor also calls it, in | 152 // If this is not called externally, the LogMessage ctor also calls it, in |
153 // which case the logging start time will be the time of the first LogMessage | 153 // which case the logging start time will be the time of the first LogMessage |
154 // instance is created. | 154 // instance is created. |
155 static uint32 LogStartTime(); | 155 static uint32_t LogStartTime(); |
156 | 156 |
157 // Returns the wall clock equivalent of |LogStartTime|, in seconds from the | 157 // Returns the wall clock equivalent of |LogStartTime|, in seconds from the |
158 // epoch. | 158 // epoch. |
159 static uint32 WallClockStartTime(); | 159 static uint32_t WallClockStartTime(); |
160 | 160 |
161 // LogThreads: Display the thread identifier of the current thread | 161 // LogThreads: Display the thread identifier of the current thread |
162 static void LogThreads(bool on = true); | 162 static void LogThreads(bool on = true); |
163 | 163 |
164 // LogTimestamps: Display the elapsed time of the program | 164 // LogTimestamps: Display the elapsed time of the program |
165 static void LogTimestamps(bool on = true); | 165 static void LogTimestamps(bool on = true); |
166 | 166 |
167 // These are the available logging channels | 167 // These are the available logging channels |
168 // Debug: Debug console on Windows, otherwise stderr | 168 // Debug: Debug console on Windows, otherwise stderr |
169 static void LogToDebug(LoggingSeverity min_sev); | 169 static void LogToDebug(LoggingSeverity min_sev); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 // The Android debug output tag. | 212 // The Android debug output tag. |
213 std::string tag_; | 213 std::string tag_; |
214 | 214 |
215 // String data generated in the constructor, that should be appended to | 215 // String data generated in the constructor, that should be appended to |
216 // the message before output. | 216 // the message before output. |
217 std::string extra_; | 217 std::string extra_; |
218 | 218 |
219 // If time it takes to write to stream is more than this, log one | 219 // If time it takes to write to stream is more than this, log one |
220 // additional warning about it. | 220 // additional warning about it. |
221 uint32 warn_slow_logs_delay_; | 221 uint32_t warn_slow_logs_delay_; |
222 | 222 |
223 // Global lock for the logging subsystem | 223 // Global lock for the logging subsystem |
224 static CriticalSection crit_; | 224 static CriticalSection crit_; |
225 | 225 |
226 // dbg_sev_ is the thresholds for those output targets | 226 // dbg_sev_ is the thresholds for those output targets |
227 // min_sev_ is the minimum (most verbose) of those levels, and is used | 227 // min_sev_ is the minimum (most verbose) of those levels, and is used |
228 // as a short-circuit in the logging macros to identify messages that won't | 228 // as a short-circuit in the logging macros to identify messages that won't |
229 // be logged. | 229 // be logged. |
230 // ctx_sev_ is the minimum level at which file context is displayed | 230 // ctx_sev_ is the minimum level at which file context is displayed |
231 static LoggingSeverity min_sev_, dbg_sev_, ctx_sev_; | 231 static LoggingSeverity min_sev_, dbg_sev_, ctx_sev_; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 #define PLOG(sev, err) \ | 359 #define PLOG(sev, err) \ |
360 LOG_ERR_EX(sev, err) | 360 LOG_ERR_EX(sev, err) |
361 | 361 |
362 // TODO(?): Add an "assert" wrapper that logs in the same manner. | 362 // TODO(?): Add an "assert" wrapper that logs in the same manner. |
363 | 363 |
364 #endif // LOG | 364 #endif // LOG |
365 | 365 |
366 } // namespace rtc | 366 } // namespace rtc |
367 | 367 |
368 #endif // WEBRTC_BASE_LOGGING_H_ | 368 #endif // WEBRTC_BASE_LOGGING_H_ |
OLD | NEW |