| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 @implementation RTCFileLogger { | 40 @implementation RTCFileLogger { |
| 41 BOOL _hasStarted; | 41 BOOL _hasStarted; |
| 42 NSString *_dirPath; | 42 NSString *_dirPath; |
| 43 NSUInteger _maxFileSize; | 43 NSUInteger _maxFileSize; |
| 44 rtc::scoped_ptr<rtc::FileRotatingLogSink> _logSink; | 44 rtc::scoped_ptr<rtc::FileRotatingLogSink> _logSink; |
| 45 } | 45 } |
| 46 | 46 |
| 47 @synthesize severity = _severity; | 47 @synthesize severity = _severity; |
| 48 @synthesize rotationType = _rotationType; | 48 @synthesize rotationType = _rotationType; |
| 49 @synthesize shouldDisableBuffering = _shouldDisableBuffering; |
| 49 | 50 |
| 50 - (instancetype)init { | 51 - (instancetype)init { |
| 51 NSArray *paths = NSSearchPathForDirectoriesInDomains( | 52 NSArray *paths = NSSearchPathForDirectoriesInDomains( |
| 52 NSDocumentDirectory, NSUserDomainMask, YES); | 53 NSDocumentDirectory, NSUserDomainMask, YES); |
| 53 NSString *documentsDirPath = [paths firstObject]; | 54 NSString *documentsDirPath = [paths firstObject]; |
| 54 NSString *defaultDirPath = | 55 NSString *defaultDirPath = |
| 55 [documentsDirPath stringByAppendingPathComponent:kDefaultLogDirName]; | 56 [documentsDirPath stringByAppendingPathComponent:kDefaultLogDirName]; |
| 56 return [self initWithDirPath:defaultDirPath | 57 return [self initWithDirPath:defaultDirPath |
| 57 maxFileSize:kDefaultMaxFileSize]; | 58 maxFileSize:kDefaultMaxFileSize]; |
| 58 } | 59 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, | 115 new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, |
| 115 _maxFileSize)); | 116 _maxFileSize)); |
| 116 break; | 117 break; |
| 117 } | 118 } |
| 118 if (!_logSink->Init()) { | 119 if (!_logSink->Init()) { |
| 119 LOG(LS_ERROR) << "Failed to open log files at path: " | 120 LOG(LS_ERROR) << "Failed to open log files at path: " |
| 120 << _dirPath.UTF8String; | 121 << _dirPath.UTF8String; |
| 121 _logSink.reset(); | 122 _logSink.reset(); |
| 122 return; | 123 return; |
| 123 } | 124 } |
| 125 if (_shouldDisableBuffering) { |
| 126 _logSink->DisableBuffering(); |
| 127 } |
| 124 rtc::LogMessage::LogThreads(true); | 128 rtc::LogMessage::LogThreads(true); |
| 125 rtc::LogMessage::LogTimestamps(true); | 129 rtc::LogMessage::LogTimestamps(true); |
| 126 rtc::LogMessage::AddLogToStream(_logSink.get(), [self rtcSeverity]); | 130 rtc::LogMessage::AddLogToStream(_logSink.get(), [self rtcSeverity]); |
| 127 _hasStarted = YES; | 131 _hasStarted = YES; |
| 128 } | 132 } |
| 129 | 133 |
| 130 - (void)stop { | 134 - (void)stop { |
| 131 if (!_hasStarted) { | 135 if (!_hasStarted) { |
| 132 return; | 136 return; |
| 133 } | 137 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case kRTCFileLoggerSeverityInfo: | 183 case kRTCFileLoggerSeverityInfo: |
| 180 return rtc::LS_INFO; | 184 return rtc::LS_INFO; |
| 181 case kRTCFileLoggerSeverityWarning: | 185 case kRTCFileLoggerSeverityWarning: |
| 182 return rtc::LS_WARNING; | 186 return rtc::LS_WARNING; |
| 183 case kRTCFileLoggerSeverityError: | 187 case kRTCFileLoggerSeverityError: |
| 184 return rtc::LS_ERROR; | 188 return rtc::LS_ERROR; |
| 185 } | 189 } |
| 186 } | 190 } |
| 187 | 191 |
| 188 @end | 192 @end |
| OLD | NEW |