Classes
The following classes are available globally.
-
A
LogFormatterconfigured to be ideal for writing human-readable log files.By default, this formatter:
- Uses
.defaultas theTimestampStyle - Uses a custom
SeverityStylethat pads the capitalized severity name - Uses
.hexas theCallingThreadStyle - Uses default field separator delimiters
- Outputs the source code filename and line number of the call site
Each of these settings can be overridden during instantiation.
See moreDeclaration
Swift
open class ReadableLogFormatter: StandardLogFormatter - Uses
-
A
See moreLogFormatterthat outputs Xcode-bound trace information for eachLogEntrythat has aPayloadof.trace.Declaration
Swift
public final class XcodeTraceLogFormatter: FieldBasedLogFormatter
-
A
See moreLogConfigurationoptimized for use when running within Xcode.Declaration
Swift
open class XcodeLogConfiguration: ConsoleLogConfiguration
-
A
LogRecorderimplementation that maintains a set of daily rotating log files, kept for a user-specified number of days.See moreImportant
ARotatingLogFileRecorderinstance assumes full control over the log directory specified by itsdirectoryPathproperty. Please see the initializer documentation for details.Declaration
Swift
open class RotatingLogFileRecorder: LogRecorderBase
-
The
See moreStandardOutputLogRecorderis anOutputStreamLogRecorderthat writes log messages to the standard output stream (`stdout`
) of the running process.Declaration
Swift
open class StandardOutputLogRecorder: OutputStreamLogRecorder
-
A
See moreLogConfigurationthat uses an underlyingRotatingLogFileRecorderto maintain a directory of log files that are rotated on a daily basis.Declaration
Swift
open class RotatingLogFileConfiguration: BasicLogConfiguration
-
The
See moreOutputStreamLogRecorderlogs messages by writing to the standard output stream of the running process.Declaration
Swift
open class OutputStreamLogRecorder: LogRecorderBase
-
In case the name didn’t give it away, the
See moreBasicLogConfigurationclass provides a basic implementation of theLogConfigurationprotocol.Declaration
Swift
open class BasicLogConfiguration: LogConfiguration
-
The
BufferedLogRecorderis a genericLogRecorderthat buffers the log messages passed to itsrecord()function.Construction requires a
createBufferItemfunction, which is responsible for converting theLogEntryand formatted messageStringinto the genericBufferItemtype.Three specific subclasses are also provided which will buffer a different
BufferItemtype for each call torecord():BufferedMessageRecorderstoresStrings containing the formatted log message.BufferedLogEntryRecorderstores theLogEntryvalues passed torecord().BufferedLogEntryMessageRecorderstores a(LogEntry, String)tuple containing theLogEntryand formatted log message.
Declaration
Swift
open class BufferedLogRecorder<BufferItem>: LogRecorderBase -
The
See moreBufferedMessageRecorderbuffers the formatted log messages passed to itsrecord()function.Declaration
Swift
open class BufferedMessageRecorder: BufferedLogRecorder<String> -
Declaration
Swift
open class BufferedLogEntryRecorder: BufferedLogRecorder<LogEntry> -
The
See moreBufferedLogEntryMessageRecorderbuffers eachLogEntryand formatted message passed to itsrecord()function.Declaration
Swift
open class BufferedLogEntryMessageRecorder: BufferedLogRecorder<(LogEntry, String)>
-
A
LogRecorderimplementation that appends log entries to a file.See moreNote
FileLogRecorderis a simple log appender that provides no mechanism for file rotation or truncation. Unless you manually manage the log file when aFileLogRecorderdoesn’t have it open, you will end up with an ever-growing file. Use aRotatingLogFileRecorderinstead if you’d rather not have to concern yourself with such details.Declaration
Swift
open class FileLogRecorder: LogRecorderBase
-
The
FieldBasedLogFormatterprovides a simple interface for constructing a customizedLogFormatterby specifying different fields.Let’s say you wanted to construct a
LogFormatterthat outputs the following fields separated by tabs:- The
LogEntry‘stimestampproperty as a UNIX time value - The
severityof theLogEntryas a numeric value - The
Payloadof theLogEntry
You could do this by constructing a
FieldBasedLogFormatteras follows:
See morelet formatter = FieldBasedLogFormatter(fields: [.timestamp(.unix), .delimiter(.tab), .severity(.numeric), .delimiter(.tab), .payload])Declaration
Swift
open class FieldBasedLogFormatter: ConcatenatingLogFormatter - The
-
LogReceptacles provide the low-level interface for accepting log messages.Although you could use a
See moreLogReceptacledirectly to perform all logging functions, theLogimplementation provides a higher-level interface that’s more convenient to use within your code.Declaration
Swift
public final class LogReceptacle
-
The
See moreConcatenatingLogFormatterlets you combine the output of multipleLogFormatters by concatenating their output and returning the result.Declaration
Swift
open class ConcatenatingLogFormatter: LogFormatter
-
A standard
LogConfigurationthat, by default, uses theos_log()function (via theOSLogRecorder), which is only available as of iOS 10.0, macOS 10.12, tvOS 10.0, and watchOS 3.0.If
See moreos_log()is not available, or if theStandardLogConfigurationis configured to bypass it, log messages will be written to either thestdoutorstderroutput stream of the running process.Declaration
Swift
open class ConsoleLogConfiguration: BasicLogConfiguration
-
The
StandardStreamsLogRecorderis aLogRecorderthat writes log messages to either the standard output stream (`stdout`
) or the standard error stream (`stderr`
) of the running process.Messages are directed to the appropriate stream depending on the
severityproperty of theLogEntrybeing recorded.Messages having a severity of
See more.verbose,.debugand.infowill be directed tostdout, while those with a severity of.warningand.errorare directed tostderr.Declaration
Swift
open class StandardStreamsLogRecorder: LogRecorderBase
-
A partial implementation of the
See moreLogRecorderprotocol.Declaration
Swift
open class LogRecorderBase: LogRecorder
-
The
See moreStandardErrorLogRecorderis anOutputStreamLogRecorderthat writes log messages to the standard error stream (`stderr`
) of the running process.Declaration
Swift
open class StandardErrorLogRecorder: OutputStreamLogRecorder
-
A standard
See moreLogFormatterthat provides some common customization points.Declaration
Swift
open class StandardLogFormatter: FieldBasedLogFormatter
-
A
LogFormatterconfigured to be ideal for writing machine-parsable log files.By default, this formatter:
- Uses
.unixas theTimestampStyle - Uses
.numericas theSeverityStyle - Uses
.hexas theCallingThreadStyle - Uses
.tabas theDelimiterStyle - Outputs the source code filename and line number of the call site
Each of these settings can be overridden during instantiation.
See moreDeclaration
Swift
open class ParsableLogFormatter: StandardLogFormatter - Uses
-
A
See moreLogFormatterideal for use within Xcode. This format is not well-suited for parsing.Declaration
Swift
public final class XcodeLogFormatter: LogFormatter
View on GitHub
Classes Reference