Classes
The following classes are available globally.
-
A
LogFormatter
configured to be ideal for writing human-readable log files.By default, this formatter:
- Uses
.default
as the defaultTimestampStyle
- Uses
.simple
as the defaultSeverityStyle
- Uses default field separator delimiters
- Outputs the call site and calling thread
These defaults can be overridden during instantiation.
See moreDeclaration
Swift
open class ReadableLogFormatter: StandardLogFormatter
- Uses
-
A
LogConfiguration
optimized for use when running within Xcode.The
See moreXcodeLogConfiguration
sets up a single recorder: anASLLogRecorder
configured to echo output tostdout
as well as capturing to the ASL.Declaration
Swift
open class XcodeLogConfiguration: BasicLogConfiguration
-
A
LogRecorder
implementation that maintains a set of daily rotating log files, kept for a user-specified number of days.Important
ARotatingLogFileRecorder
instance assumes full control over the log directory specified by itsdirectoryPath
property. Please see the initializer documentation for details.Declaration
Swift
open class RotatingLogFileRecorder: LogRecorderBase
-
The
See moreStandardOutputLogRecorder
logs messages by writing to the standard output stream of the running process.Declaration
Swift
open class StandardOutputLogRecorder: LogRecorderBase
-
A
See moreLogConfiguration
that uses an underlyingRotatingLogFileRecorder
to maintain a directory of log files that are rotated on a daily basis.Declaration
Swift
open class RotatingLogFileConfiguration: BasicLogConfiguration
-
In case the name didn’t give it away, the
See moreBasicLogConfiguration
class provides a basic implementation of theLogConfiguration
protocol.Declaration
Swift
open class BasicLogConfiguration: LogConfiguration
-
A
LogRecorder
implementation that appends log entries to a file.Note
FileLogRecorder
is a simple log appender that provides no mechanism for file rotation or truncation. Unless you manually manage the log file when aFileLogRecorder
doesn’t have it open, you will end up with an ever-growing file. Use aRotatingLogFileRecorder
instead if you’d rather not have to concern yourself with such details.Declaration
Swift
open class FileLogRecorder: LogRecorderBase
-
The
FieldBasedLogFormatter
provides a simple interface for constructing a customizedLogFormatter
by specifying different fields.Let’s say you wanted to construct a
LogFormatter
that outputs the following fields separated by tabs:- The
LogEntry
’stimestamp
property as a UNIX time value - The
severity
of theLogEntry
as a numeric value - The
Payload
of theLogEntry
You could do this by constructing a
FieldBasedLogFormatter
as follows:
See morelet formatter = FieldBasedLogFormatter(fields: [.Timestamp(.UNIX), .Delimiter(.Tab), .Severity(.Numeric), .Delimiter(.Tab), .Payload])
Declaration
Swift
open class FieldBasedLogFormatter: ConcatenatingLogFormatter
- The
-
LogReceptacle
s provide the low-level interface for accepting log messages.Although you could use a
See moreLogReceptacle
directly to perform all logging functions, theLog
implementation provides a higher-level interface that’s more convenient to use within your code.Declaration
Swift
public final class LogReceptacle
-
The
See moreConcatenatingLogFormatter
lets you combine the output of multipleLogFormatter
s by contatenating their output and returning the result.Declaration
Swift
open class ConcatenatingLogFormatter: LogFormatter
-
A partial implementation of the
See moreLogRecorder
protocol.Declaration
Swift
open class LogRecorderBase: LogRecorder
-
A standard
See moreLogFormatter
that provides some common customization points.Declaration
Swift
open class StandardLogFormatter: FieldBasedLogFormatter
-
A
LogFormatter
configured to be ideal for writing machine-parsable log files.By default, this formatter:
- Uses
.unix
as the defaultTimestampStyle
- Uses
.numeric
as the defaultSeverityStyle
- Uses
.tab
as the defaultDelimiterStyle
- Outputs the call site and calling thread
These defaults can be overridden during instantiation.
See moreDeclaration
Swift
open class ParsableLogFormatter: StandardLogFormatter
- Uses
-
A
LogFormatter
ideal for use within Xcode.By default, this formatter:
- Uses
.default
as the defaultTimestampStyle
- Uses
.xcode
as the defaultSeverityStyle
- Uses default field separator delimiters
- Outputs the call site
- Does not output the calling thread
These defaults can be overridden by providing alternate values to the initializer.
See moreDeclaration
Swift
open class XcodeLogFormatter: StandardLogFormatter
- Uses