Chromium Code Reviews| Index: talk/app/webrtc/objc/RTCFileLogger.mm |
| diff --git a/talk/app/webrtc/objc/RTCFileLogger.mm b/talk/app/webrtc/objc/RTCFileLogger.mm |
| index c4e469655d1a884f67d0608b76a90d77271d0a40..b543dcd1f4209f7062b35f8bd6b4d3340e02db83 100644 |
| --- a/talk/app/webrtc/objc/RTCFileLogger.mm |
| +++ b/talk/app/webrtc/objc/RTCFileLogger.mm |
| @@ -35,15 +35,17 @@ |
| NSString *const kDefaultLogDirName = @"webrtc_logs"; |
| NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. |
| +const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; |
| @implementation RTCFileLogger { |
| BOOL _hasStarted; |
| NSString *_dirPath; |
| NSUInteger _maxFileSize; |
| - rtc::scoped_ptr<rtc::CallSessionFileRotatingLogSink> _logSink; |
| + rtc::scoped_ptr<rtc::FileRotatingLogSink> _logSink; |
| } |
| @synthesize severity = _severity; |
| +@synthesize rotationType = _rotationType; |
| - (instancetype)init { |
| NSArray *paths = NSSearchPathForDirectoriesInDomains( |
| @@ -57,6 +59,14 @@ NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. |
| - (instancetype)initWithDirPath:(NSString *)dirPath |
| maxFileSize:(NSUInteger)maxFileSize { |
| + return [self initWithDirPath:dirPath |
| + maxFileSize:maxFileSize |
| + rotationType:kRTCFileLoggerRotationTypeMiddle]; |
| +} |
| + |
| +- (instancetype)initWithDirPath:(NSString *)dirPath |
| + maxFileSize:(NSUInteger)maxFileSize |
| + rotationType:(RTCFileLoggerRotationType)rotationType { |
| NSParameterAssert(dirPath.length); |
| NSParameterAssert(maxFileSize); |
| if (self = [super init]) { |
| @@ -91,8 +101,15 @@ NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. |
| if (_hasStarted) { |
| return; |
| } |
| - _logSink.reset(new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, |
| - _maxFileSize)); |
| + if (_rotationType == kRTCFileLoggerRotationTypeOldest) { |
|
tkchin_webrtc
2015/11/16 21:37:25
use a switch here so we don't miss it if we add ne
Chuck
2015/12/04 22:42:57
Done.
|
| + _logSink.reset(new rtc::FileRotatingLogSink(_dirPath.UTF8String, |
| + kRTCFileLoggerRotatingLogPrefix, |
|
tkchin_webrtc
2015/11/16 21:37:25
suggest using different prefixes for the different
Chuck
2015/12/04 22:42:57
It isn't immediately obvious, but they do use diff
|
| + _maxFileSize, |
| + _maxFileSize / 10)); |
| + } else { |
| + _logSink.reset(new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, |
| + _maxFileSize)); |
| + } |
| if (!_logSink->Init()) { |
| LOG(LS_ERROR) << "Failed to open log files at path: " |
| << _dirPath.UTF8String; |
| @@ -120,8 +137,13 @@ NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. |
| return nil; |
| } |
| NSMutableData* logData = [NSMutableData data]; |
| - rtc::scoped_ptr<rtc::CallSessionFileRotatingStream> stream( |
| - new rtc::CallSessionFileRotatingStream(_dirPath.UTF8String)); |
| + rtc::scoped_ptr<rtc::FileRotatingStream> stream; |
| + if (_rotationType == kRTCFileLoggerRotationTypeOldest) { |
|
tkchin_webrtc
2015/11/16 21:37:25
ditto switch
Chuck
2015/12/04 22:42:57
Done.
|
| + stream.reset(new rtc::FileRotatingStream(_dirPath.UTF8String, |
| + kRTCFileLoggerRotatingLogPrefix)); |
| + } else { |
| + stream.reset(new rtc::CallSessionFileRotatingStream(_dirPath.UTF8String)); |
| + } |
| if (!stream->Open()) { |
| return logData; |
| } |