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 default TimestampStyle
    • Uses .Simple as the default SeverityStyle
    • 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 more

    Declaration

    Swift

    open class ReadableLogFormatter: StandardLogFormatter
  • 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 separate LogRecorders: a StandardOutputLogRecorder, which will be configured to perform colorization of the logs within the Xcode console, and an ASLLogRecorder 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 XcodeLogConfiguration will configure only a single recorder: an ASLLogRecorder configured to echo output to stdout as well as capturing to the ASL.

    See more

    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

    A RotatingLogFileRecorder instance assumes full control over the log directory specified by its directoryPath property. Please see the initializer documentation for details.
    See more

    Declaration

    Swift

    open class RotatingLogFileRecorder: LogRecorderBase
  • 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 a FileLogRecorder doesn’t have it open, you will end up with an ever-growing file. Use a RotatingLogFileRecorder instead if you’d rather not have to concern yourself with such details.
    See more

    Declaration

    Swift

    open class FileLogRecorder: LogRecorderBase
  • The FieldBasedLogFormatter provides a simple interface for constructing a customized LogFormatter by specifying different fields.

    Let’s say you wanted to construct a LogFormatter that outputs the following fields separated by tabs:

    • The LogEntry’s timestamp property as a UNIX time value
    • The severity of the LogEntry as a numeric value
    • The Payload of the LogEntry

    You could do this by constructing a FieldBasedLogFormatter as follows:

    let formatter = FieldBasedLogFormatter(fields: [.Timestamp(.UNIX),
                                                    .Delimiter(.Tab),
                                                    .Severity(.Numeric),
                                                    .Delimiter(.Tab),
                                                    .Payload])
    
    See more

    Declaration

    Swift

    open class FieldBasedLogFormatter: ConcatenatingLogFormatter
  • LogReceptacles provide the low-level interface for accepting log messages.

    Although you could use a LogReceptacle directly to perform all logging functions, the Log implementation provides a higher-level interface that’s more convenient to use within your code.

    See more

    Declaration

    Swift

    public final class LogReceptacle
  • A LogFormatter ideal for use within Xcode.

    By default, this formatter:

    • Uses .Default as the default TimestampStyle
    • Uses .Xcode as the default SeverityStyle
    • 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 more

    Declaration

    Swift

    open class XcodeLogFormatter: StandardLogFormatter