Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: webrtc/base/logsinks.cc

Issue 1230823009: Add rotating log file stream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/base/logsinks.h"
12
13 #include <string>
14
15 namespace rtc {
16 FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path,
17 const std::string& log_prefix,
18 size_t max_log_size,
19 size_t num_log_files)
20 : FileRotatingLogSink(new FileRotatingStream(log_dir_path,
21 log_prefix,
22 max_log_size,
23 num_log_files)) {
24 }
25
26 FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream)
27 : stream_(stream) {
28 }
29
30 FileRotatingLogSink::~FileRotatingLogSink() {
31 }
32
33 void FileRotatingLogSink::OnLogMessage(const std::string& message) {
34 if (!stream_ || stream_->GetState() != SS_OPEN) {
35 LOG(LS_WARNING) << "Init() must be called before adding this sink.";
36 return;
37 }
38 stream_->WriteAll(message.c_str(), message.size(), nullptr, nullptr);
39 }
40
41 bool FileRotatingLogSink::Init() {
42 return stream_->Open();
43 }
44
45 MobileDeviceLogSink::MobileDeviceLogSink(const std::string& log_dir_path,
46 size_t max_total_log_size)
47 : FileRotatingLogSink(
48 new MobileDeviceLogStream(log_dir_path, max_total_log_size)) {
49 }
50
51 MobileDeviceLogSink::~MobileDeviceLogSink() {
52 }
53
54 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698