open class FileLogRecorder: LogRecorderBase
LogRecorder implementation that appends log entries to a file.
FileLogRecorderis a simple log appender that provides no mechanism for file rotation or truncation. Unless you manually manage the log file when a
FileLogRecorderdoesn’t have it open, you will end up with an ever-growing file. Use a
RotatingLogFileRecorderinstead if you’d rather not have to concern yourself with such details.
The path of the file to which log entries will be written.
open let filePath: String
Attempts to initialize a new
FileLogRecorderinstance to use the given file path and log formatters. This will fail if
filePathcould not be opened for writing.
public init?(filePath: String, formatters: [LogFormatter])
The path of the file to be written. The containing directory must exist and be writable by the process. If the file does not yet exist, it will be created; if it does exist, new log messages will be appended to the end of the file.
An array of
LogFormatters to use for formatting log entries to be recorded by the receiver. Each formatter is consulted in sequence, and the formatted string returned by the first formatter to yield a non-
nilvalue will be recorded. If every formatter returns
nil, the log entry is silently ignored and not recorded.
Called by the
LogReceptacleto record the specified log message.
This function is only called if one of the
formattersassociated with the receiver returned a non-
nilstring for the given
open override func record(message: String, for entry: LogEntry, currentQueue: DispatchQueue, synchronousMode: Bool)
The message to record.
The GCD queue on which the function is being executed.
true, the recording is being done in synchronous mode, and the recorder should act accordingly.