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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 bool LogMessage::thread_, LogMessage::timestamp_; | 117 bool LogMessage::thread_, LogMessage::timestamp_; |
118 | 118 |
119 LogMessage::LogMessage(const char* file, | 119 LogMessage::LogMessage(const char* file, |
120 int line, | 120 int line, |
121 LoggingSeverity sev, | 121 LoggingSeverity sev, |
122 LogErrorContext err_ctx, | 122 LogErrorContext err_ctx, |
123 int err, | 123 int err, |
124 const char* module) | 124 const char* module) |
125 : severity_(sev), tag_(kLibjingle) { | 125 : severity_(sev), tag_(kLibjingle) { |
126 if (timestamp_) { | 126 if (timestamp_) { |
127 int64_t time = TimeSince(LogStartTime()); | 127 // Use SystemTimeMillis so that even if tests use fake clocks, the timestamp |
| 128 // in log messages represents the real system time. |
| 129 int64_t time = TimeDiff(SystemTimeMillis(), LogStartTime()); |
128 // Also ensure WallClockStartTime is initialized, so that it matches | 130 // Also ensure WallClockStartTime is initialized, so that it matches |
129 // LogStartTime. | 131 // LogStartTime. |
130 WallClockStartTime(); | 132 WallClockStartTime(); |
131 print_stream_ << "[" << std::setfill('0') << std::setw(3) << (time / 1000) | 133 print_stream_ << "[" << std::setfill('0') << std::setw(3) << (time / 1000) |
132 << ":" << std::setw(3) << (time % 1000) << std::setfill(' ') | 134 << ":" << std::setw(3) << (time % 1000) << std::setfill(' ') |
133 << "] "; | 135 << "] "; |
134 } | 136 } |
135 | 137 |
136 if (thread_) { | 138 if (thread_) { |
137 PlatformThreadId id = CurrentThreadId(); | 139 PlatformThreadId id = CurrentThreadId(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 205 |
204 CritScope cs(&g_log_crit); | 206 CritScope cs(&g_log_crit); |
205 for (auto& kv : streams_) { | 207 for (auto& kv : streams_) { |
206 if (severity_ >= kv.second) { | 208 if (severity_ >= kv.second) { |
207 kv.first->OnLogMessage(str); | 209 kv.first->OnLogMessage(str); |
208 } | 210 } |
209 } | 211 } |
210 } | 212 } |
211 | 213 |
212 int64_t LogMessage::LogStartTime() { | 214 int64_t LogMessage::LogStartTime() { |
213 static const int64_t g_start = TimeMillis(); | 215 static const int64_t g_start = SystemTimeMillis(); |
214 return g_start; | 216 return g_start; |
215 } | 217 } |
216 | 218 |
217 uint32_t LogMessage::WallClockStartTime() { | 219 uint32_t LogMessage::WallClockStartTime() { |
218 static const uint32_t g_start_wallclock = time(NULL); | 220 static const uint32_t g_start_wallclock = time(NULL); |
219 return g_start_wallclock; | 221 return g_start_wallclock; |
220 } | 222 } |
221 | 223 |
222 void LogMessage::LogThreads(bool on) { | 224 void LogMessage::LogThreads(bool on) { |
223 thread_ = on; | 225 thread_ = on; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 548 } |
547 | 549 |
548 if (state) { | 550 if (state) { |
549 state->unprintable_count_[input] = consecutive_unprintable; | 551 state->unprintable_count_[input] = consecutive_unprintable; |
550 } | 552 } |
551 } | 553 } |
552 | 554 |
553 ////////////////////////////////////////////////////////////////////// | 555 ////////////////////////////////////////////////////////////////////// |
554 | 556 |
555 } // namespace rtc | 557 } // namespace rtc |
OLD | NEW |