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’srecordFormattedString()function. Formatters are consulted sequentially and given an opportunity to return a formatted string for eachLogEntry. The first non-nilreturn value is sent to the log for recording. Typically, an implementation of this protocol would not hard-code theLogFormatters it uses, but would instead provide a constructor that accepts an array ofLogFormatters, 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
LogReceptacleto record the formatted log message.Note
This function is only called if one of the
formattersassociated with the receiver returned a non-nilstring for the givenLogEntry.Declaration
Swift
func record(message: String, for entry: LogEntry, currentQueue: DispatchQueue, synchronousMode: Bool)Parameters
messageThe message to record.
entryThe
LogEntryfor whichmessagewas created.currentQueueThe GCD queue on which the function is being executed.
synchronousModeIf
true, the recording is being done in synchronous mode, and the recorder should act accordingly.
View on GitHub
LogRecorder Protocol Reference