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