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

Side by Side Diff: webrtc/base/objc/RTCFileLogger.mm

Issue 1692243003: Move RTCFileLogger to webrtc/base/objc. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove symlinks Created 4 years, 10 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/objc/RTCFileLogger.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
1 /* 1 /*
2 * libjingle 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
3 * Copyright 2015 Google Inc.
4 * 3 *
5 * Redistribution and use in source and binary forms, with or without 4 * Use of this source code is governed by a BSD-style license
6 * modification, are permitted provided that the following conditions are met: 5 * that can be found in the LICENSE file in the root of the source
7 * 6 * tree. An additional intellectual property rights grant can be found
8 * 1. Redistributions of source code must retain the above copyright notice, 7 * in the file PATENTS. All contributing project authors may
9 * this list of conditions and the following disclaimer. 8 * be found in the AUTHORS file in the root of the source tree.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 9 */
27 10
28 #import "RTCFileLogger.h" 11 #import "RTCFileLogger.h"
29 12
30 #include "webrtc/base/checks.h" 13 #include "webrtc/base/checks.h"
31 #include "webrtc/base/filerotatingstream.h" 14 #include "webrtc/base/filerotatingstream.h"
32 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
33 #include "webrtc/base/logsinks.h" 16 #include "webrtc/base/logsinks.h"
34 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
35 18
36 NSString *const kDefaultLogDirName = @"webrtc_logs"; 19 NSString *const kDefaultLogDirName = @"webrtc_logs";
37 NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB. 20 NSUInteger const kDefaultMaxFileSize = 10 * 1024 * 1024; // 10MB.
38 const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; 21 const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log";
39 22
40 @implementation RTCFileLogger { 23 @implementation RTCFileLogger {
41 BOOL _hasStarted; 24 BOOL _hasStarted;
42 NSString *_dirPath; 25 NSString *_dirPath;
43 NSUInteger _maxFileSize; 26 NSUInteger _maxFileSize;
44 rtc::scoped_ptr<rtc::FileRotatingLogSink> _logSink; 27 rtc::scoped_ptr<rtc::FileRotatingLogSink> _logSink;
45 } 28 }
46 29
47 @synthesize severity = _severity; 30 @synthesize severity = _severity;
48 @synthesize rotationType = _rotationType; 31 @synthesize rotationType = _rotationType;
49 @synthesize shouldDisableBuffering = _shouldDisableBuffering;
tkchin_webrtc 2016/02/23 00:13:40 add these back?
hjon_webrtc 2016/02/23 16:38:37 Done.
50 32
51 - (instancetype)init { 33 - (instancetype)init {
52 NSArray *paths = NSSearchPathForDirectoriesInDomains( 34 NSArray *paths = NSSearchPathForDirectoriesInDomains(
53 NSDocumentDirectory, NSUserDomainMask, YES); 35 NSDocumentDirectory, NSUserDomainMask, YES);
54 NSString *documentsDirPath = [paths firstObject]; 36 NSString *documentsDirPath = [paths firstObject];
55 NSString *defaultDirPath = 37 NSString *defaultDirPath =
56 [documentsDirPath stringByAppendingPathComponent:kDefaultLogDirName]; 38 [documentsDirPath stringByAppendingPathComponent:kDefaultLogDirName];
57 return [self initWithDirPath:defaultDirPath 39 return [self initWithDirPath:defaultDirPath
58 maxFileSize:kDefaultMaxFileSize]; 40 maxFileSize:kDefaultMaxFileSize];
59 } 41 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, 97 new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String,
116 _maxFileSize)); 98 _maxFileSize));
117 break; 99 break;
118 } 100 }
119 if (!_logSink->Init()) { 101 if (!_logSink->Init()) {
120 LOG(LS_ERROR) << "Failed to open log files at path: " 102 LOG(LS_ERROR) << "Failed to open log files at path: "
121 << _dirPath.UTF8String; 103 << _dirPath.UTF8String;
122 _logSink.reset(); 104 _logSink.reset();
123 return; 105 return;
124 } 106 }
125 if (_shouldDisableBuffering) {
126 _logSink->DisableBuffering();
127 }
128 rtc::LogMessage::LogThreads(true); 107 rtc::LogMessage::LogThreads(true);
129 rtc::LogMessage::LogTimestamps(true); 108 rtc::LogMessage::LogTimestamps(true);
130 rtc::LogMessage::AddLogToStream(_logSink.get(), [self rtcSeverity]); 109 rtc::LogMessage::AddLogToStream(_logSink.get(), [self rtcSeverity]);
131 _hasStarted = YES; 110 _hasStarted = YES;
132 } 111 }
133 112
134 - (void)stop { 113 - (void)stop {
135 if (!_hasStarted) { 114 if (!_hasStarted) {
136 return; 115 return;
137 } 116 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 case kRTCFileLoggerSeverityInfo: 162 case kRTCFileLoggerSeverityInfo:
184 return rtc::LS_INFO; 163 return rtc::LS_INFO;
185 case kRTCFileLoggerSeverityWarning: 164 case kRTCFileLoggerSeverityWarning:
186 return rtc::LS_WARNING; 165 return rtc::LS_WARNING;
187 case kRTCFileLoggerSeverityError: 166 case kRTCFileLoggerSeverityError:
188 return rtc::LS_ERROR; 167 return rtc::LS_ERROR;
189 } 168 }
190 } 169 }
191 170
192 @end 171 @end
OLDNEW
« no previous file with comments | « webrtc/base/objc/RTCFileLogger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698