ConsoleLogConfiguration

open class ConsoleLogConfiguration: BasicLogConfiguration

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.

  • Governs when a ConsoleLogConfiguration directs log messages to stdout and stderr.

    See more

    Declaration

    Swift

    public enum StandardStreamsMode
  • Initializes a new ConsoleLogConfiguration instance.

    Warning

    Setting either debugMode or verboseDebugMode to true will result in synchronousMode being used when recording log entries. Synchronous mode is helpful while debugging, as it ensures that logs are always up-to-date when debug breakpoints are hit. However, synchronous mode can have a negative influence on performance and is therefore not recommended for use in production code.

    Declaration

    Swift

    public convenience init(minimumSeverity: LogSeverity = .info, debugMode: Bool = false, verboseDebugMode: Bool = false, stdStreamsMode: StandardStreamsMode = .useAsFallback, filters: [LogFilter] = [], formatters: [LogFormatter])

    Parameters

    minimumSeverity

    The minimum supported LogSeverity. Any LogEntry having a severity less than minimumSeverity will be silently ignored.

    debugMode

    If true, the value of minimumSeverity will be lowered (if necessary) to .debug and synchronousMode will be used when recording log entries.

    verboseDebugMode

    If true, the value of minimumSeverity will be lowered (if necessary) to .verbose and synchronousMode will be used when recording log entries.

    stdStreamsMode

    A StandardStreamsMode value that governs when standard console streams (i.e., stdout and stderr) should be used for recording log output.

    filters

    The LogFilters to use when deciding whether a given LogEntry should be passed along for recording.

    formatters

    An array of LogFormatters to use when formatting log entries.

  • Initializes a new ConsoleLogConfiguration instance.

    Warning

    Setting either debugMode or verboseDebugMode to true will result in synchronousMode being used when recording log entries. Synchronous mode is helpful while debugging, as it ensures that logs are always up-to-date when debug breakpoints are hit. However, synchronous mode can have a negative influence on performance and is therefore not recommended for use in production code.

    Declaration

    Swift

    public init(minimumSeverity: LogSeverity = .info, debugMode: Bool = false, verboseDebugMode: Bool = false, stdStreamsMode: StandardStreamsMode = .useAsFallback, filters: [LogFilter] = [], osLogFormatters: [LogFormatter], stdoutFormatters: [LogFormatter])

    Parameters

    minimumSeverity

    The minimum supported LogSeverity. Any LogEntry having a severity less than minimumSeverity will be silently ignored.

    debugMode

    If true, the value of minimumSeverity will be lowered (if necessary) to .debug and synchronousMode will be used when recording log entries.

    verboseDebugMode

    If true, the value of minimumSeverity will be lowered (if necessary) to .verbose and synchronousMode will be used when recording log entries.

    stdStreamsMode

    A StandardStreamsMode value that governs when standard console streams (i.e., stdout and stderr) should be used for recording log output.

    filters

    The LogFilters to use when deciding whether a given LogEntry should be passed along for recording.

    osLogFormatters

    An array of LogFormatters to use when formatting log entries bound for the OSLogRecorder.

    stdoutFormatters

    An array of LogFormatters to use when formatting log entries bound for the StandardOutputLogRecorder.

  • Determines whether the os_log() function will be used given the runtime environment and the value of mode.

    Declaration

    Swift

    public static func willUseOSLog(mode: StandardStreamsMode)
            -> Bool

    Parameters

    mode

    A StandardStreamsMode value that governs when standard console streams (i.e., stdout and stderr) should be used for recording log output.

    Return Value

    true if os_log() is available and will be used given the value of mode.

  • Determines whether the stdout and stderr streams should be used given the runtime environment and the value of mode.

    Declaration

    Swift

    public static func shouldUseStandardStreams(mode: StandardStreamsMode)
            -> Bool

    Parameters

    mode

    A StandardStreamsMode value that governs when standard console streams (i.e., stdout and stderr) should be used for recording log output.

    Return Value

    true if stdout and stderr will be used given the value of mode.