Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifndef WEBRTC_BASE_FILE_ROTATING_LOG_SINK_H_ | |
| 12 #define WEBRTC_BASE_FILE_ROTATING_LOG_SINK_H_ | |
| 13 | |
| 14 #include <string> | |
| 15 | |
| 16 #include "webrtc/base/constructormagic.h" | |
| 17 #include "webrtc/base/logging.h" | |
| 18 #include "webrtc/base/scoped_ptr.h" | |
| 19 #include "webrtc/base/stream.h" | |
| 20 | |
| 21 namespace rtc { | |
| 22 | |
| 23 // Log sink that uses a FileRotatingStream to write to disk. | |
| 24 // Init() must be called before adding this sink. | |
| 25 class FileRotatingLogSink : public LogSink { | |
| 26 public: | |
| 27 // |num_log_files| must be greater than 1 and |max_log_size| must be greater | |
| 28 // than 0. | |
| 29 FileRotatingLogSink(const std::string& log_dir_path, | |
| 30 const std::string& log_prefix, | |
| 31 size_t max_log_size, | |
| 32 size_t num_log_files); | |
| 33 ~FileRotatingLogSink() override; | |
| 34 | |
| 35 // Writes the message to the current file. It will spill over to the next | |
| 36 // file if needed. | |
| 37 void OnLogMessage(const std::string& message) override; | |
| 38 | |
| 39 // Deletes any existing files in the directory and creates a new log file. | |
| 40 virtual bool Init(); | |
| 41 | |
| 42 protected: | |
| 43 explicit FileRotatingLogSink(FileRotatingStream* stream); | |
| 44 | |
| 45 private: | |
| 46 scoped_ptr<FileRotatingStream> stream_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(FileRotatingLogSink); | |
| 49 }; | |
| 50 | |
| 51 // Log sink that uses a MobileDeviceLogSink to write to disk. | |
|
jiayl2
2015/07/20 23:27:05
nit: uses a MobileDeviceLogStream ...
tkchin_webrtc
2015/07/21 20:39:12
Done.
| |
| 52 // Init() must be called before adding this sink. | |
| 53 class MobileDeviceLogSink : public FileRotatingLogSink { | |
| 54 public: | |
| 55 MobileDeviceLogSink(const std::string& log_dir_path, | |
| 56 size_t max_total_log_size); | |
| 57 ~MobileDeviceLogSink() override; | |
| 58 | |
| 59 private: | |
| 60 scoped_ptr<MobileDeviceLogStream> stream_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(MobileDeviceLogSink); | |
| 63 }; | |
| 64 | |
| 65 } // namespace rtc | |
| 66 | |
| 67 #endif // WEBRTC_BASE_FILE_ROTATING_LOG_SINK_H_ | |
| OLD | NEW |