Conforms to NSObject
Declared in DDLog.h

Tasks

  • – logMessage: required method
  •   logFormatter

    Formatters may optionally be added to any logger.

    property required method
  • – didAddLogger

    Since logging is asynchronous, adding and removing loggers is also asynchronous. In other words, the loggers are added and removed at appropriate times with regards to log messages.

  • – willRemoveLogger
  • – flush

    Some loggers may buffer IO for optimization purposes. For example, a database logger may only save occasionaly as the disk IO is slow. In such loggers, this method should be implemented to flush any pending IO.

  •   loggerQueue

    Each logger is executed concurrently with respect to the other loggers. Thus, a dedicated dispatch queue is used for each logger. Logger implementations may optionally choose to provide their own dispatch queue.

    property
  •   loggerName

    If the logger implementation does not choose to provide its own queue, one will automatically be created for it. The created queue will receive its name from this method. This may be helpful for debugging or profiling reasons.

    property

Properties

logFormatter

@property (nonatomic, strong) id<DDLogFormatter> logFormatter
Discussion

Formatters may optionally be added to any logger.

If no formatter is set, the logger simply logs the message as it is given in logMessage, or it may use its own built in formatting style.

Declared In

DDLog.h

loggerName

@property (nonatomic, readonly) NSString *loggerName
Discussion

If the logger implementation does not choose to provide its own queue, one will automatically be created for it. The created queue will receive its name from this method. This may be helpful for debugging or profiling reasons.

Declared In

DDLog.h

loggerQueue

@property (nonatomic, DISPATCH_QUEUE_REFERENCE_TYPE, readonly) dispatch_queue_t loggerQueue
Discussion

Each logger is executed concurrently with respect to the other loggers. Thus, a dedicated dispatch queue is used for each logger. Logger implementations may optionally choose to provide their own dispatch queue.

Declared In

DDLog.h

Instance Methods

didAddLogger

- (void)didAddLogger
Discussion

Since logging is asynchronous, adding and removing loggers is also asynchronous. In other words, the loggers are added and removed at appropriate times with regards to log messages.

  • Loggers will not receive log messages that were executed prior to when they were added.
  • Loggers will not receive log messages that were executed after they were removed.

These methods are executed in the logging thread/queue. This is the same thread/queue that will execute every logMessage: invocation. Loggers may use these methods for thread synchronization or other setup/teardown tasks.

Declared In

DDLog.h

flush

- (void)flush
Discussion

Some loggers may buffer IO for optimization purposes. For example, a database logger may only save occasionaly as the disk IO is slow. In such loggers, this method should be implemented to flush any pending IO.

This allows invocations of DDLog’s flushLog method to be propogated to loggers that need it.

Note that DDLog’s flushLog method is invoked automatically when the application quits, and it may be also invoked manually by the developer prior to application crashes, or other such reasons.

Declared In

DDLog.h

logMessage:

- (void)logMessage:(DDLogMessage *)logMessage

willRemoveLogger

- (void)willRemoveLogger