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 |
11 #include "webrtc/rtc_base/logging.h" | |
12 #include "webrtc/rtc_base/fileutils.h" | 11 #include "webrtc/rtc_base/fileutils.h" |
13 #include "webrtc/rtc_base/gunit.h" | 12 #include "webrtc/rtc_base/gunit.h" |
| 13 #include "webrtc/rtc_base/logging.h" |
| 14 #include "webrtc/rtc_base/nullsocketserver.h" |
14 #include "webrtc/rtc_base/pathutils.h" | 15 #include "webrtc/rtc_base/pathutils.h" |
15 #include "webrtc/rtc_base/stream.h" | 16 #include "webrtc/rtc_base/stream.h" |
16 #include "webrtc/rtc_base/thread.h" | 17 #include "webrtc/rtc_base/thread.h" |
17 | 18 |
18 namespace rtc { | 19 namespace rtc { |
19 | 20 |
20 template <typename Base> | 21 template <typename Base> |
21 class LogSinkImpl | 22 class LogSinkImpl |
22 : public LogSink, | 23 : public LogSink, |
23 public Base { | 24 public Base { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 EXPECT_EQ(LS_NONE, LogMessage::GetLogToStream(&stream2)); | 82 EXPECT_EQ(LS_NONE, LogMessage::GetLogToStream(&stream2)); |
82 EXPECT_EQ(LS_NONE, LogMessage::GetLogToStream(&stream1)); | 83 EXPECT_EQ(LS_NONE, LogMessage::GetLogToStream(&stream1)); |
83 | 84 |
84 EXPECT_EQ(sev, LogMessage::GetLogToStream(nullptr)); | 85 EXPECT_EQ(sev, LogMessage::GetLogToStream(nullptr)); |
85 } | 86 } |
86 | 87 |
87 // Ensure we don't crash when adding/removing streams while threads are going. | 88 // Ensure we don't crash when adding/removing streams while threads are going. |
88 // We should restore the correct global state at the end. | 89 // We should restore the correct global state at the end. |
89 class LogThread : public Thread { | 90 class LogThread : public Thread { |
90 public: | 91 public: |
| 92 LogThread() : Thread(std::unique_ptr<SocketServer>(new NullSocketServer())) {} |
| 93 |
91 ~LogThread() override { | 94 ~LogThread() override { |
92 Stop(); | 95 Stop(); |
93 } | 96 } |
94 | 97 |
95 private: | 98 private: |
96 void Run() override { | 99 void Run() override { |
97 // LS_SENSITIVE to avoid cluttering up any real logging going on | 100 // LS_SENSITIVE to avoid cluttering up any real logging going on |
98 LOG(LS_SENSITIVE) << "LOG"; | 101 LOG(LS_SENSITIVE) << "LOG"; |
99 } | 102 } |
100 }; | 103 }; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 finish = TimeMillis(); | 156 finish = TimeMillis(); |
154 | 157 |
155 LogMessage::RemoveLogToStream(&stream); | 158 LogMessage::RemoveLogToStream(&stream); |
156 stream.Close(); | 159 stream.Close(); |
157 Filesystem::DeleteFile(path); | 160 Filesystem::DeleteFile(path); |
158 | 161 |
159 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " ms"; | 162 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " ms"; |
160 } | 163 } |
161 | 164 |
162 } // namespace rtc | 165 } // namespace rtc |
OLD | NEW |