blob: 281be4e31ff76fb08ab11e230dee0e5069ebf56a [file] [log] [blame]
Jon Hjelle6140fcc2016-02-24 16:33:12 -08001/*
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#import <Foundation/Foundation.h>
12
13typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) {
tkchin8b9ca952016-03-31 12:08:03 -070014 RTCFileLoggerSeverityVerbose,
15 RTCFileLoggerSeverityInfo,
16 RTCFileLoggerSeverityWarning,
17 RTCFileLoggerSeverityError
Jon Hjelle6140fcc2016-02-24 16:33:12 -080018};
19
20typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) {
tkchin8b9ca952016-03-31 12:08:03 -070021 RTCFileLoggerTypeCall,
22 RTCFileLoggerTypeApp,
Jon Hjelle6140fcc2016-02-24 16:33:12 -080023};
24
tkchin8b9ca952016-03-31 12:08:03 -070025NS_ASSUME_NONNULL_BEGIN
26
Jon Hjelle6140fcc2016-02-24 16:33:12 -080027// This class intercepts WebRTC logs and saves them to a file. The file size
28// will not exceed the given maximum bytesize. When the maximum bytesize is
29// reached, logs are rotated according to the rotationType specified.
30// For kRTCFileLoggerTypeCall, logs from the beginning and the end
31// are preserved while the middle section is overwritten instead.
32// For kRTCFileLoggerTypeApp, the oldest log is overwritten.
33// This class is not threadsafe.
34@interface RTCFileLogger : NSObject
35
36// The severity level to capture. The default is kRTCFileLoggerSeverityInfo.
37@property(nonatomic, assign) RTCFileLoggerSeverity severity;
38
39// The rotation type for this file logger. The default is
40// kRTCFileLoggerTypeCall.
41@property(nonatomic, readonly) RTCFileLoggerRotationType rotationType;
42
43// Disables buffering disk writes. Should be set before |start|. Buffering
44// is enabled by default for performance.
45@property(nonatomic, assign) BOOL shouldDisableBuffering;
46
47// Default constructor provides default settings for dir path, file size and
48// rotation type.
49- (instancetype)init;
50
51// Create file logger with default rotation type.
52- (instancetype)initWithDirPath:(NSString *)dirPath
53 maxFileSize:(NSUInteger)maxFileSize;
54
55- (instancetype)initWithDirPath:(NSString *)dirPath
56 maxFileSize:(NSUInteger)maxFileSize
57 rotationType:(RTCFileLoggerRotationType)rotationType
58 NS_DESIGNATED_INITIALIZER;
59
60// Starts writing WebRTC logs to disk if not already started. Overwrites any
61// existing file(s).
62- (void)start;
63
64// Stops writing WebRTC logs to disk. This method is also called on dealloc.
65- (void)stop;
66
67// Returns the current contents of the logs, or nil if start has been called
68// without a stop.
69- (NSData *)logData;
70
71@end
tkchin8b9ca952016-03-31 12:08:03 -070072
73NS_ASSUME_NONNULL_END
74