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

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: Fix header 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
« no previous file with comments | « webrtc/base/logsinks.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
17 FileRotatingLogSink::FileRotatingLogSink(const std::string& log_dir_path,
18 const std::string& log_prefix,
19 size_t max_log_size,
20 size_t num_log_files)
21 : FileRotatingLogSink(new FileRotatingStream(log_dir_path,
22 log_prefix,
23 max_log_size,
24 num_log_files)) {
25 }
26
27 FileRotatingLogSink::FileRotatingLogSink(FileRotatingStream* stream)
28 : stream_(stream) {
29 }
30
31 FileRotatingLogSink::~FileRotatingLogSink() {
32 }
33
34 void FileRotatingLogSink::OnLogMessage(const std::string& message) {
35 if (!stream_ || stream_->GetState() != SS_OPEN) {
36 LOG(LS_WARNING) << "Init() must be called before adding this sink.";
37 return;
38 }
39 stream_->WriteAll(message.c_str(), message.size(), nullptr, nullptr);
40 }
41
42 bool FileRotatingLogSink::Init() {
43 return stream_->Open();
44 }
45
46 CallSessionFileRotatingLogSink::CallSessionFileRotatingLogSink(
47 const std::string& log_dir_path,
48 size_t max_total_log_size)
49 : FileRotatingLogSink(
50 new CallSessionFileRotatingStream(log_dir_path, max_total_log_size)) {
51 }
52
53 CallSessionFileRotatingLogSink::~CallSessionFileRotatingLogSink() {
54 }
55
56 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/logsinks.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698