Classes

The following classes are available globally.

  • 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 standard LogConfiguration that, by default, uses the os_log() function (via the OSLogRecorder), which is only available as of iOS 10.0, macOS 10.12, tvOS 10.0, and watchOS 3.0.

    If os_log() is not available, or if the StandardLogConfiguration is configured to bypass it, log messages will be written to either the stdout or stderr output stream of the running process.

    See more

    Declaration

    Swift

    open class ConsoleLogConfiguration: BasicLogConfiguration
  • The StandardStreamsLogRecorder is a LogRecorder that 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 severity property of the LogEntry being recorded.

    Messages having a severity of .verbose, .debug and .info will be directed to stdout, while those with a severity of .warning and .error are directed to stderr.

    See more

    Declaration

    Swift

    open class StandardStreamsLogRecorder: LogRecorderBase