AWSDDLogFileManager
Objective-C
@protocol AWSDDLogFileManager <NSObject>
Swift
protocol AWSDDLogFileManager : NSObjectProtocol
The LogFileManager protocol is designed to allow you to control all aspects of your log files.
The primary purpose of this is to allow you to do something with the log files after they have been rolled. Perhaps you want to compress them to save disk space. Perhaps you want to upload them to an FTP server. Perhaps you want to run some analytics on the file.
A default LogFileManager is, of course, provided. The default LogFileManager simply deletes old log files according to the maximumNumberOfLogFiles property.
This protocol provides various methods to fetch the list of log files.
There are two variants: sorted and unsorted. If sorting is not necessary, the unsorted variant is obviously faster. The sorted variant will return an array sorted by when the log files were created, with the most recently created log file at index 0, and the oldest log file at the end of the array.
You can fetch only the log file paths (full path including name), log file names (name only),
or an array of AWSDDLogFileInfo
objects.
The AWSDDLogFileInfo
class is documented below, and provides a handy wrapper that
gives you easy access to various file attributes such as the creation date or the file size.
-
The maximum number of archived log files to keep on disk. For example, if this property is set to 3, then the LogFileManager will only keep 3 archived log files (plus the current active log file) on disk. Once the active log file is rolled/archived, then the oldest of the existing 3 rolled/archived log files is deleted.
You may optionally disable this option by setting it to zero.
Declaration
Objective-C
@required @property (atomic, assign, unsafe_unretained, readwrite) NSUInteger maximumNumberOfLogFiles;
Swift
var maximumNumberOfLogFiles: UInt { get set }
-
The maximum space that logs can take. On rolling logfile all old logfiles that exceed logFilesDiskQuota will be deleted.
You may optionally disable this option by setting it to zero.
Declaration
Objective-C
@required @property (atomic, assign, unsafe_unretained, readwrite) unsigned long long logFilesDiskQuota;
Swift
var logFilesDiskQuota: UInt64 { get set }
-
Returns the logs directory (path)
Declaration
Objective-C
@required @property (nonatomic, copy, readonly) NSString *logsDirectory;
Swift
var logsDirectory: String! { get }
-
Returns an array of
NSString
objects, each of which is the filePath to an existing log file on disk.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<NSString *> *unsortedLogFilePaths;
Swift
var unsortedLogFilePaths: [String]! { get }
-
Returns an array of
NSString
objects, each of which is the fileName of an existing log file on disk.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<NSString *> *unsortedLogFileNames;
Swift
var unsortedLogFileNames: [String]! { get }
-
Returns an array of
AWSDDLogFileInfo
objects, each representing an existing log file on disk, and containing important information about the log file such as it’s modification date and size.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<AWSDDLogFileInfo *> *unsortedLogFileInfos;
Swift
var unsortedLogFileInfos: [AWSDDLogFileInfo]! { get }
-
Just like the
unsortedLogFilePaths
method, but sorts the array. The items in the array are sorted by creation date. The first item in the array will be the most recently created log file.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<NSString *> *sortedLogFilePaths;
Swift
var sortedLogFilePaths: [String]! { get }
-
Just like the
unsortedLogFileNames
method, but sorts the array. The items in the array are sorted by creation date. The first item in the array will be the most recently created log file.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<NSString *> *sortedLogFileNames;
Swift
var sortedLogFileNames: [String]! { get }
-
Just like the
unsortedLogFileInfos
method, but sorts the array. The items in the array are sorted by creation date. The first item in the array will be the most recently created log file.Declaration
Objective-C
@required @property (nonatomic, strong, readonly) NSArray<AWSDDLogFileInfo *> *sortedLogFileInfos;
Swift
var sortedLogFileInfos: [AWSDDLogFileInfo]! { get }
-
Generates a new unique log file path, and creates the corresponding log file.
Declaration
Objective-C
- (NSString *)createNewLogFile;
Swift
func createNewLogFile() -> String!
-
Called when a log file was archieved
Declaration
Objective-C
- (void)didArchiveLogFile:(NSString *)logFilePath;
Swift
optional func didArchiveLogFile(atPath logFilePath: String!)
-
Called when the roll action was executed and the log was archieved
Declaration
Objective-C
- (void)didRollAndArchiveLogFile:(NSString *)logFilePath;
Swift
optional func didRollAndArchiveLogFile(atPath logFilePath: String!)