LogRecorder

public protocol LogRecorder

Each LogRecorder instance is responsible recording formatted log messages (along with their accompanying LogEntry instances) to an underlying log facility or data store.

  • The LogFormatters that should be used to create a formatted log string for passing to the receiver’s recordFormattedString() function. Formatters are consulted sequentially and given an opportunity to return a formatted string for each LogEntry. The first non-nil return value is sent to the log for recording. Typically, an implementation of this protocol would not hard-code the LogFormatters it uses, but would instead provide a constructor that accepts an array of LogFormatters, which it will subsequently return from this property.

    Declaration

    Swift

    var formatters: [LogFormatter]
  • Returns the GCD queue that will be used when executing tasks related to the receiver. Log formatting and recording will be performed using this queue. A serial queue is typically used, such as when the underlying log facility is inherently single-threaded and/or proper message ordering wouldn’t be ensured otherwise. However, a concurrent queue may also be used, and might be appropriate when logging to databases or network endpoints.

    Declaration

    Swift

    var queue: DispatchQueue
  • Called by the LogReceptacle to record the formatted log message.

    Note

    This function is only called if one of the formatters associated with the receiver returned a non-nil string for the given LogEntry.

    Declaration

    Swift

    func record(message: String, for entry: LogEntry, currentQueue: DispatchQueue, synchronousMode: Bool)

    Parameters

    message

    The message to record.

    entry

    The LogEntry for which message was created.

    currentQueue

    The GCD queue on which the function is being executed.

    synchronousMode

    If true, the recording is being done in synchronous mode, and the recorder should act accordingly.