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
See moreConsoleLogConfigurationdirects log messages tostdoutandstderr.Declaration
Swift
public enum StandardStreamsMode -
Initializes a new
ConsoleLogConfigurationinstance.Warning
Setting either
debugModeorverboseDebugModetotruewill result insynchronousModebeing 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
minimumSeverityThe minimum supported
LogSeverity. AnyLogEntryhaving aseverityless thanminimumSeveritywill be silently ignored.debugModeIf
true, the value ofminimumSeveritywill be lowered (if necessary) to.debugandsynchronousModewill be used when recording log entries.verboseDebugModeIf
true, the value ofminimumSeveritywill be lowered (if necessary) to.verboseandsynchronousModewill be used when recording log entries.stdStreamsModeA
StandardStreamsModevalue that governs when standard console streams (i.e.,stdoutandstderr) should be used for recording log output.filtersThe
LogFilters to use when deciding whether a givenLogEntryshould be passed along for recording.formattersAn array of
LogFormatters to use when formatting log entries. -
init(minimumSeverity:debugMode:verboseDebugMode:stdStreamsMode:filters:osLogFormatters:stdoutFormatters:)Initializes a new
ConsoleLogConfigurationinstance.Warning
Setting either
debugModeorverboseDebugModetotruewill result insynchronousModebeing 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
minimumSeverityThe minimum supported
LogSeverity. AnyLogEntryhaving aseverityless thanminimumSeveritywill be silently ignored.debugModeIf
true, the value ofminimumSeveritywill be lowered (if necessary) to.debugandsynchronousModewill be used when recording log entries.verboseDebugModeIf
true, the value ofminimumSeveritywill be lowered (if necessary) to.verboseandsynchronousModewill be used when recording log entries.stdStreamsModeA
StandardStreamsModevalue that governs when standard console streams (i.e.,stdoutandstderr) should be used for recording log output.filtersThe
LogFilters to use when deciding whether a givenLogEntryshould be passed along for recording.osLogFormattersAn array of
LogFormatters to use when formatting log entries bound for theOSLogRecorder.stdoutFormattersAn array of
LogFormatters to use when formatting log entries bound for theStandardOutputLogRecorder.
-
Determines whether the
os_log()function will be used given the runtime environment and the value ofmode.Declaration
Swift
public static func willUseOSLog(mode: StandardStreamsMode) -> BoolParameters
modeA
StandardStreamsModevalue that governs when standard console streams (i.e.,stdoutandstderr) should be used for recording log output.Return Value
trueifos_log()is available and will be used given the value ofmode. -
Determines whether the
stdoutandstderrstreams should be used given the runtime environment and the value ofmode.Declaration
Swift
public static func shouldUseStandardStreams(mode: StandardStreamsMode) -> BoolParameters
modeA
StandardStreamsModevalue that governs when standard console streams (i.e.,stdoutandstderr) should be used for recording log output.Return Value
trueifstdoutandstderrwill be used given the value ofmode.
View on GitHub
ConsoleLogConfiguration Class Reference