AWSDDFileLogger

Objective-C

@interface AWSDDFileLogger : AWSDDAbstractLogger <AWSDDLogger>

Swift

class AWSDDFileLogger : AWSDDAbstractLogger, AWSDDLogger

The standard implementation for a file logger

  • Default initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    convenience init()
  • Designated initializer, requires a AWSDDLogFileManager instance. A global queue w/ default priority is used to run callbacks. If needed, specify queue using initWithLogFileManager:completionQueue:.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithLogFileManager:
        (nonnull id<AWSDDLogFileManager>)logFileManager;

    Swift

    convenience init(logFileManager: AWSDDLogFileManager)
  • Designated initializer, requires a AWSDDLogFileManager instance. The completionQueue is used to execute didArchiveLogFile:wasRolled:, and the callback in rollLogFileWithCompletionBlock:. If nil, a global queue w/ default priority is used.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithLogFileManager:(nonnull id<AWSDDLogFileManager>)logFileManager
               completionQueue:(nullable dispatch_queue_t)dispatchQueue;

    Swift

    init(logFileManager: AWSDDLogFileManager, completionQueue dispatchQueue: DispatchQueue?)
  • Deprecated

    Use -willLogMessage:

    Deprecated. Use willLogMessage:

    Declaration

    Objective-C

    - (void)willLogMessage;

    Swift

    func willLogMessage()
  • Deprecated

    Use -didLogMessage:

    Deprecated. Use didLogMessage:

    Declaration

    Objective-C

    - (void)didLogMessage;

    Swift

    func didLogMessage()
  • Called when the logger is about to write message. Call super before your implementation.

    Declaration

    Objective-C

    - (void)willLogMessage:(nonnull AWSDDLogFileInfo *)logFileInfo;

    Swift

    func willLogMessage(_ logFileInfo: AWSDDLogFileInfo)
  • Called when the logger wrote message. Call super after your implementation.

    Declaration

    Objective-C

    - (void)didLogMessage:(nonnull AWSDDLogFileInfo *)logFileInfo;

    Swift

    func didLogMessage(_ logFileInfo: AWSDDLogFileInfo)
  • Writes all in-memory log data to the permanent storage. Call super before your implementation. Don’t call this method directly, instead use the [AWSDDLog flushLog] to ensure all log messages are included in flush.

    Declaration

    Objective-C

    - (void)flush;

    Swift

    func flush()
  • Called when the logger checks archive or not current log file. Override this method to extend standard behavior. By default returns NO. This is executed directly on the logger’s internal queue, so keep processing light!

    Declaration

    Objective-C

    - (BOOL)shouldArchiveRecentLogFileInfo:
        (nonnull AWSDDLogFileInfo *)recentLogFileInfo;

    Swift

    func shouldArchiveRecentLogFileInfo(_ recentLogFileInfo: AWSDDLogFileInfo) -> Bool
  • Log File Rolling:

    maximumFileSize: The approximate maximum size (in bytes) to allow log files to grow. If a log file is larger than this value after a log statement is appended, then the log file is rolled.

    rollingFrequency How often to roll the log file. The frequency is given as an NSTimeInterval, which is a double that specifies the interval in seconds. Once the log file gets to be this old, it is rolled.

    doNotReuseLogFiles When set, will always create a new log file at application launch.

    Both the maximumFileSize and the rollingFrequency are used to manage rolling. Whichever occurs first will cause the log file to be rolled.

    For example: The rollingFrequency is 24 hours, but the log file surpasses the maximumFileSize after only 20 hours. The log file will be rolled at that 20 hour mark. A new log file will be created, and the 24 hour timer will be restarted.

    You may optionally disable rolling due to filesize by setting maximumFileSize to zero. If you do so, rolling is based solely on rollingFrequency.

    You may optionally disable rolling due to time by setting rollingFrequency to zero (or any non-positive number). If you do so, rolling is based solely on maximumFileSize.

    If you disable both maximumFileSize and rollingFrequency, then the log file won’t ever be rolled. This is strongly discouraged.

    Declaration

    Objective-C

    @property unsigned long long maximumFileSize;

    Swift

    var maximumFileSize: UInt64 { get set }
  • See description for maximumFileSize

    Declaration

    Objective-C

    @property NSTimeInterval rollingFrequency;

    Swift

    var rollingFrequency: TimeInterval { get set }
  • See description for maximumFileSize

    Declaration

    Objective-C

    @property BOOL doNotReuseLogFiles;

    Swift

    var doNotReuseLogFiles: Bool { get set }
  • The AWSDDLogFileManager instance can be used to retrieve the list of log files, and configure the maximum number of archived log files to keep.

    See

    AWSDDLogFileManager.maximumNumberOfLogFiles

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) id<AWSDDLogFileManager> _Nonnull logFileManager;

    Swift

    var logFileManager: AWSDDLogFileManager { get }
  • When using a custom formatter you can set the logMessage method not to append \n character after each output. This allows for some greater flexibility with custom formatters. Default value is YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL automaticallyAppendNewlineForCustomFormatters;

    Swift

    var automaticallyAppendNewlineForCustomFormatters: Bool { get set }
  • You can optionally force the current log file to be rolled with this method. CompletionBlock will be called on main queue.

    Declaration

    Objective-C

    - (void)rollLogFileWithCompletionBlock:(nullable void (^)(void))completionBlock;

    Swift

    func rollLogFile() async
  • Deprecated

    Use -rollLogFileWithCompletionBlock:

    Method is deprecated. @deprecated Use rollLogFileWithCompletionBlock: method instead.

    Declaration

    Objective-C

    - (void)rollLogFile;

    Swift

    func rollLogFile()
  • Returns the log file that should be used. If there is an existing log file that is suitable, within the constraints of maximumFileSize and rollingFrequency, then it is returned.

    Otherwise a new file is created and returned. If this failes, NULL is returned.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) AWSDDLogFileInfo *currentLogFileInfo;

    Swift

    var currentLogFileInfo: AWSDDLogFileInfo? { get }

Buffering

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)wrapWithBuffer;

    Swift

    func wrapWithBuffer() -> Self
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)unwrapFromBuffer;

    Swift

    func unwrapFromBuffer() -> Self