| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 TraceToStderr::TraceToStderr(bool override_time) | 31 TraceToStderr::TraceToStderr(bool override_time) |
| 32 : override_time_(override_time), | 32 : override_time_(override_time), |
| 33 time_seconds_(0) { | 33 time_seconds_(0) { |
| 34 Trace::set_level_filter(kLevelFilter); | 34 Trace::set_level_filter(kLevelFilter); |
| 35 Trace::CreateTrace(); | 35 Trace::CreateTrace(); |
| 36 Trace::SetTraceCallback(this); | 36 Trace::SetTraceCallback(this); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TraceToStderr::~TraceToStderr() { | 39 TraceToStderr::~TraceToStderr() { |
| 40 Trace::SetTraceCallback(NULL); | 40 Trace::SetTraceCallback(nullptr); |
| 41 Trace::ReturnTrace(); | 41 Trace::ReturnTrace(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void TraceToStderr::SetTimeSeconds(float time) { time_seconds_ = time; } | 44 void TraceToStderr::SetTimeSeconds(float time) { time_seconds_ = time; } |
| 45 | 45 |
| 46 void TraceToStderr::Print(TraceLevel level, const char* msg_array, int length) { | 46 void TraceToStderr::Print(TraceLevel level, const char* msg_array, int length) { |
| 47 if (level & kLevelFilter) { | 47 if (level & kLevelFilter) { |
| 48 assert(length > Trace::kBoilerplateLength); | 48 assert(length > Trace::kBoilerplateLength); |
| 49 std::string msg = msg_array; | 49 std::string msg = msg_array; |
| 50 std::string msg_log = msg.substr(Trace::kBoilerplateLength); | 50 std::string msg_log = msg.substr(Trace::kBoilerplateLength); |
| 51 if (override_time_) { | 51 if (override_time_) { |
| 52 fprintf(stderr, "%.2fs %s\n", time_seconds_, msg_log.c_str()); | 52 fprintf(stderr, "%.2fs %s\n", time_seconds_, msg_log.c_str()); |
| 53 } else { | 53 } else { |
| 54 std::string msg_time = msg.substr(Trace::kTimestampPosition, | 54 std::string msg_time = msg.substr(Trace::kTimestampPosition, |
| 55 Trace::kTimestampLength); | 55 Trace::kTimestampLength); |
| 56 fprintf(stderr, "%s %s\n", msg_time.c_str(), msg_log.c_str()); | 56 fprintf(stderr, "%s %s\n", msg_time.c_str(), msg_log.c_str()); |
| 57 } | 57 } |
| 58 fflush(stderr); | 58 fflush(stderr); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace test | 62 } // namespace test |
| 63 } // namespace webrtc | 63 } // namespace webrtc |
| OLD | NEW |