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
- Does not perform text colorization
These defaults can be overridden during instantiation.
See moreDeclaration
Swift
open class ReadableLogFormatter: StandardLogFormatter
- Uses
-
A
LogConfiguration
optimized for use when running within Xcode.By default, this configuration will attempt to detect the presence of the XcodeColors plug-in, and—if it is present—will enable text colorization.
If text colorization is used, the
XcodeLogConfiguration
will enable two separateLogRecorder
s: aStandardOutputLogRecorder
, which will be configured to perform colorization of the logs within the Xcode console, and anASLLogRecorder
which will not use colorization. This ensures that the colorization escape sequences used within Xcode do not end up in the Apple System Log (ASL), where they will look like garbage characters.If no colorization is used, then the
See moreXcodeLogConfiguration
will configure only 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
- Does not perform text colorization
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
- Performs text colorization if XcodeColors is installed and enabled
These defaults can be overridden during instantiation.
See moreDeclaration
Swift
open class XcodeLogFormatter: StandardLogFormatter
- Uses