DDAbstractDatabaseLogger

Objective-C

@interface DDAbstractDatabaseLogger : DDAbstractLogger {
  NSUInteger _saveThreshold;
  NSTimeInterval _saveInterval;
  NSTimeInterval _maxAge;
  NSTimeInterval _deleteInterval;
  BOOL _deleteOnEverySave;
  NSInteger _saveTimerSuspended;
  NSUInteger _unsavedCount;
  dispatch_time_t _unsavedTime;
  dispatch_source_t _saveTimer;
  dispatch_time_t _lastDeleteTime;
  dispatch_source_t _deleteTimer;
}

Swift

class DDAbstractDatabaseLogger : DDAbstractLogger

This class provides an abstract implementation of a database logger.

That is, it provides the base implementation for a database logger to build atop of. All that is needed for a concrete database logger is to extend this class and override the methods in the implementation file that are prefixed with “db_”.

  • Undocumented

    Declaration

    Objective-C

    NSUInteger _saveThreshold
  • Undocumented

    Declaration

    Objective-C

    NSTimeInterval _saveInterval
  • Undocumented

    Declaration

    Objective-C

    NSTimeInterval _maxAge
  • Undocumented

    Declaration

    Objective-C

    NSTimeInterval _deleteInterval
  • Undocumented

    Declaration

    Objective-C

    BOOL _deleteOnEverySave
  • Undocumented

    Declaration

    Objective-C

    NSInteger _saveTimerSuspended
  • Undocumented

    Declaration

    Objective-C

    NSUInteger _unsavedCount
  • Undocumented

    Declaration

    Objective-C

    dispatch_time_t _unsavedTime
  • Undocumented

    Declaration

    Objective-C

    dispatch_source_t _saveTimer
  • Undocumented

    Declaration

    Objective-C

    dispatch_time_t _lastDeleteTime
  • Undocumented

    Declaration

    Objective-C

    dispatch_source_t _deleteTimer
  • Specifies how often to save the data to disk. Since saving is an expensive operation (disk io) it is not done after every log statement. These properties allow you to configure how/when the logger saves to disk.

    A save is done when either (whichever happens first):

    • The number of unsaved log entries reaches saveThreshold
    • The amount of time since the oldest unsaved log entry was created reaches saveInterval

    You can optionally disable the saveThreshold by setting it to zero. If you disable the saveThreshold you are entirely dependent on the saveInterval.

    You can optionally disable the saveInterval by setting it to zero (or a negative value). If you disable the saveInterval you are entirely dependent on the saveThreshold.

    It’s not wise to disable both saveThreshold and saveInterval.

    The default saveThreshold is 500. The default saveInterval is 60 seconds.

    Declaration

    Objective-C

    @property NSUInteger saveThreshold;

    Swift

    var saveThreshold: UInt { get set }
  • See the description for the saveThreshold property

    Declaration

    Objective-C

    @property NSTimeInterval saveInterval;

    Swift

    var saveInterval: TimeInterval { get set }
  • It is likely you don’t want the log entries to persist forever. Doing so would allow the database to grow infinitely large over time.

    The maxAge property provides a way to specify how old a log statement can get before it should get deleted from the database.

    The deleteInterval specifies how often to sweep for old log entries. Since deleting is an expensive operation (disk io) is is done on a fixed interval.

    An alternative to the deleteInterval is the deleteOnEverySave option. This specifies that old log entries should be deleted during every save operation.

    You can optionally disable the maxAge by setting it to zero (or a negative value). If you disable the maxAge then old log statements are not deleted.

    You can optionally disable the deleteInterval by setting it to zero (or a negative value).

    If you disable both deleteInterval and deleteOnEverySave then old log statements are not deleted.

    It’s not wise to enable both deleteInterval and deleteOnEverySave.

    The default maxAge is 7 days. The default deleteInterval is 5 minutes. The default deleteOnEverySave is NO.

    Declaration

    Objective-C

    @property NSTimeInterval maxAge;

    Swift

    var maxAge: TimeInterval { get set }
  • See the description for the maxAge property

    Declaration

    Objective-C

    @property NSTimeInterval deleteInterval;

    Swift

    var deleteInterval: TimeInterval { get set }
  • See the description for the maxAge property

    Declaration

    Objective-C

    @property BOOL deleteOnEverySave;

    Swift

    var deleteOnEverySave: Bool { get set }
  • Forces a save of any pending log entries (flushes log entries to disk).

    Declaration

    Objective-C

    - (void)savePendingLogEntries;

    Swift

    func savePendingLogEntries()
  • Removes any log entries that are older than maxAge.

    Declaration

    Objective-C

    - (void)deleteOldLogEntries;

    Swift

    func deleteOldLogEntries()