OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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/base/logsinks.h" | 11 #include "webrtc/base/logsinks.h" |
12 | 12 |
| 13 #include <iostream> |
13 #include <string> | 14 #include <string> |
14 | 15 |
| 16 #include "webrtc/base/checks.h" |
| 17 |
15 namespace rtc { | 18 namespace rtc { |
16 | 19 |
17 FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path, | 20 FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path, |
18 const std::string& log_prefix, | 21 const std::string& log_prefix, |
19 size_t max_log_size, | 22 size_t max_log_size, |
20 size_t num_log_files) | 23 size_t num_log_files) |
21 : FileRotatingLogSink(new FileRotatingStream(log_dir_path, | 24 : FileRotatingLogSink(new FileRotatingStream(log_dir_path, |
22 log_prefix, | 25 log_prefix, |
23 max_log_size, | 26 max_log_size, |
24 num_log_files)) { | 27 num_log_files)) { |
25 } | 28 } |
26 | 29 |
27 FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream) | 30 FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream) |
28 : stream_(stream) { | 31 : stream_(stream) { |
| 32 DCHECK(stream); |
29 } | 33 } |
30 | 34 |
31 FileRotatingLogSink::~FileRotatingLogSink() { | 35 FileRotatingLogSink::~FileRotatingLogSink() { |
32 } | 36 } |
33 | 37 |
34 void FileRotatingLogSink::OnLogMessage(const std::string& message) { | 38 void FileRotatingLogSink::OnLogMessage(const std::string& message) { |
35 if (!stream_ || stream_->GetState() != SS_OPEN) { | 39 if (stream_->GetState() != SS_OPEN) { |
36 LOG(LS_WARNING) << "Init() must be called before adding this sink."; | 40 std::cerr << "Init() must be called before adding this sink." << std::endl; |
37 return; | 41 return; |
38 } | 42 } |
39 stream_->WriteAll(message.c_str(), message.size(), nullptr, nullptr); | 43 stream_->WriteAll(message.c_str(), message.size(), nullptr, nullptr); |
40 } | 44 } |
41 | 45 |
42 bool FileRotatingLogSink::Init() { | 46 bool FileRotatingLogSink::Init() { |
43 return stream_->Open(); | 47 return stream_->Open(); |
44 } | 48 } |
45 | 49 |
| 50 bool FileRotatingLogSink::DisableBuffering() { |
| 51 return stream_->DisableBuffering(); |
| 52 } |
| 53 |
46 CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink( | 54 CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink( |
47 const std::string& log_dir_path, | 55 const std::string& log_dir_path, |
48 size_t max_total_log_size) | 56 size_t max_total_log_size) |
49 : FileRotatingLogSink( | 57 : FileRotatingLogSink( |
50 new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) { | 58 new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) { |
51 } | 59 } |
52 | 60 |
53 CallSessionFileRotatingLogSink::~CallSessionFileRotatingLogSink() { | 61 CallSessionFileRotatingLogSink::~CallSessionFileRotatingLogSink() { |
54 } | 62 } |
55 | 63 |
56 } // namespace rtc | 64 } // namespace rtc |
OLD | NEW |