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 moreConsoleLogConfiguration
directs log messages tostdout
andstderr
.Declaration
Swift
public enum StandardStreamsMode
-
Initializes a new
ConsoleLogConfiguration
instance.Warning
Setting either
debugMode
orverboseDebugMode
totrue
will result insynchronousMode
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
. AnyLogEntry
having aseverity
less thanminimumSeverity
will be silently ignored.debugMode
If
true
, the value ofminimumSeverity
will be lowered (if necessary) to.debug
andsynchronousMode
will be used when recording log entries.verboseDebugMode
If
true
, the value ofminimumSeverity
will be lowered (if necessary) to.verbose
andsynchronousMode
will be used when recording log entries.stdStreamsMode
A
StandardStreamsMode
value that governs when standard console streams (i.e.,stdout
andstderr
) should be used for recording log output.filters
The
LogFilter
s to use when deciding whether a givenLogEntry
should be passed along for recording.formatters
An array of
LogFormatter
s to use when formatting log entries. -
init(minimumSeverity:debugMode:verboseDebugMode:stdStreamsMode:filters:osLogFormatters:stdoutFormatters:)
Initializes a new
ConsoleLogConfiguration
instance.Warning
Setting either
debugMode
orverboseDebugMode
totrue
will result insynchronousMode
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
. AnyLogEntry
having aseverity
less thanminimumSeverity
will be silently ignored.debugMode
If
true
, the value ofminimumSeverity
will be lowered (if necessary) to.debug
andsynchronousMode
will be used when recording log entries.verboseDebugMode
If
true
, the value ofminimumSeverity
will be lowered (if necessary) to.verbose
andsynchronousMode
will be used when recording log entries.stdStreamsMode
A
StandardStreamsMode
value that governs when standard console streams (i.e.,stdout
andstderr
) should be used for recording log output.filters
The
LogFilter
s to use when deciding whether a givenLogEntry
should be passed along for recording.osLogFormatters
An array of
LogFormatter
s to use when formatting log entries bound for theOSLogRecorder
.stdoutFormatters
An array of
LogFormatter
s 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) -> Bool
Parameters
mode
A
StandardStreamsMode
value that governs when standard console streams (i.e.,stdout
andstderr
) should be used for recording log output.Return Value
true
ifos_log()
is available and will be used given the value ofmode
. -
Determines whether the
stdout
andstderr
streams should be used given the runtime environment and the value ofmode
.Declaration
Swift
public static func shouldUseStandardStreams(mode: StandardStreamsMode) -> Bool
Parameters
mode
A
StandardStreamsMode
value that governs when standard console streams (i.e.,stdout
andstderr
) should be used for recording log output.Return Value
true
ifstdout
andstderr
will be used given the value ofmode
.