diff --git a/talk/app/webrtc/legacy_objc_api.gyp b/talk/app/webrtc/legacy_objc_api.gyp index 8aaa0f14e9..9b3bb85ed4 100755 --- a/talk/app/webrtc/legacy_objc_api.gyp +++ b/talk/app/webrtc/legacy_objc_api.gyp @@ -43,7 +43,6 @@ 'objc/RTCDataChannel.mm', 'objc/RTCEnumConverter.h', 'objc/RTCEnumConverter.mm', - 'objc/RTCFileLogger.mm', 'objc/RTCI420Frame+Internal.h', 'objc/RTCI420Frame.mm', 'objc/RTCICECandidate+Internal.h', diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index e7d550a1b0..119001da89 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -635,6 +635,8 @@ if (is_ios) { "objc/RTCCameraPreviewView.m", "objc/RTCDispatcher.h", "objc/RTCDispatcher.m", + "objc/RTCFileLogger.h", + "objc/RTCFileLogger.mm", "objc/RTCLogging.h", "objc/RTCLogging.mm", "objc/RTCMacros.h", diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp index bf397665e0..cb1eac4843 100644 --- a/webrtc/base/base.gyp +++ b/webrtc/base/base.gyp @@ -36,6 +36,8 @@ 'objc/NSString+StdString.mm', 'objc/RTCDispatcher.h', 'objc/RTCDispatcher.m', + 'objc/RTCFileLogger.h', + 'objc/RTCFileLogger.mm', 'objc/RTCLogging.h', 'objc/RTCLogging.mm', 'objc/RTCMacros.h', diff --git a/webrtc/base/objc/RTCFileLogger.h b/webrtc/base/objc/RTCFileLogger.h new file mode 100644 index 0000000000..c736012c25 --- /dev/null +++ b/webrtc/base/objc/RTCFileLogger.h @@ -0,0 +1,69 @@ +/* + * Copyright 2015 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#import + +typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) { + kRTCFileLoggerSeverityVerbose, + kRTCFileLoggerSeverityInfo, + kRTCFileLoggerSeverityWarning, + kRTCFileLoggerSeverityError +}; + +typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) { + kRTCFileLoggerTypeCall, + kRTCFileLoggerTypeApp, +}; + +// This class intercepts WebRTC logs and saves them to a file. The file size +// will not exceed the given maximum bytesize. When the maximum bytesize is +// reached, logs are rotated according to the rotationType specified. +// For kRTCFileLoggerTypeCall, logs from the beginning and the end +// are preserved while the middle section is overwritten instead. +// For kRTCFileLoggerTypeApp, the oldest log is overwritten. +// This class is not threadsafe. +@interface RTCFileLogger : NSObject + +// The severity level to capture. The default is kRTCFileLoggerSeverityInfo. +@property(nonatomic, assign) RTCFileLoggerSeverity severity; + +// The rotation type for this file logger. The default is +// kRTCFileLoggerTypeCall. +@property(nonatomic, readonly) RTCFileLoggerRotationType rotationType; + +// Disables buffering disk writes. Should be set before |start|. Buffering +// is enabled by default for performance. +@property(nonatomic, assign) BOOL shouldDisableBuffering; + +// Default constructor provides default settings for dir path, file size and +// rotation type. +- (instancetype)init; + +// Create file logger with default rotation type. +- (instancetype)initWithDirPath:(NSString *)dirPath + maxFileSize:(NSUInteger)maxFileSize; + +- (instancetype)initWithDirPath:(NSString *)dirPath + maxFileSize:(NSUInteger)maxFileSize + rotationType:(RTCFileLoggerRotationType)rotationType + NS_DESIGNATED_INITIALIZER; + +// Starts writing WebRTC logs to disk if not already started. Overwrites any +// existing file(s). +- (void)start; + +// Stops writing WebRTC logs to disk. This method is also called on dealloc. +- (void)stop; + +// Returns the current contents of the logs, or nil if start has been called +// without a stop. +- (NSData *)logData; + +@end diff --git a/talk/app/webrtc/objc/RTCFileLogger.mm b/webrtc/base/objc/RTCFileLogger.mm similarity index 77% rename from talk/app/webrtc/objc/RTCFileLogger.mm rename to webrtc/base/objc/RTCFileLogger.mm index c927f76eb6..cc3a39d0be 100644 --- a/talk/app/webrtc/objc/RTCFileLogger.mm +++ b/webrtc/base/objc/RTCFileLogger.mm @@ -1,28 +1,11 @@ /* - * libjingle - * Copyright 2015 Google Inc. + * Copyright 2015 The WebRTC project authors. All Rights Reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. */ #import "RTCFileLogger.h" diff --git a/webrtc/webrtc_examples.gyp b/webrtc/webrtc_examples.gyp index c6695dbfe2..74162a1c8d 100755 --- a/webrtc/webrtc_examples.gyp +++ b/webrtc/webrtc_examples.gyp @@ -199,6 +199,7 @@ 'type': 'static_library', 'dependencies': [ 'apprtc_common', + 'base/base.gyp:rtc_base_objc', '../talk/app/webrtc/legacy_objc_api.gyp:libjingle_peerconnection_objc', 'socketrocket', ], @@ -247,6 +248,7 @@ ], }, 'export_dependent_settings': [ + 'base/base.gyp:rtc_base_objc', '../talk/app/webrtc/legacy_objc_api.gyp:libjingle_peerconnection_objc', ], 'conditions': [