ParsableLogFormatter
open class ParsableLogFormatter: StandardLogFormatter
A LogFormatter
configured to be ideal for writing machine-parsable log files.
By default, this formatter:
- Uses
.UNIX
as the defaultTimestampStyle
- Uses
.Numeric
as the defaultSeverityStyle
- Uses
.Tab
as the defaultDelimiterStyle
- Outputs the call site and calling thread
- Does not perform text colorization
These defaults can be overridden during instantiation.
-
init(timestampStyle:severityStyle:delimiterStyle:showCallSite:showCallingThread:colorizer:colorTable:)
Initializes a new
ParsableLogFormatter
instance.Declaration
Swift
public override init(timestampStyle: TimestampStyle? = .unix, severityStyle: SeverityStyle? = .numeric, delimiterStyle: DelimiterStyle? = .tab, showCallSite: Bool = true, showCallingThread: Bool = true, colorizer: TextColorizer? = nil, colorTable: ColorTable? = nil)
Parameters
timestampStyle
Governs the formatting of the timestamp in the log output. Pass
nil
to suppress output of the timestamp.severityStyle
Governs the formatting of the
LogSeverity
in the log output. Passnil
to suppress output of the severity.delimiterStyle
If provided, overrides the default field separator delimiters. Pass
nil
to use the default delimiters.showCallSite
If
true
, the source file and line indicating the call site of the log request will be added to formatted log messages.showCallingThread
If
true
, a hexadecimal string containing an opaque identifier for the calling thread will be added to formatted log messages.colorizer
The
TextColorizer
that will be used to colorize the output of the receiver. Ifnil
, no colorization will occur.colorTable
If a
colorizer
is provided, an optionalColorTable
may also be provided to supply color information. Ifnil
,DefaultColorTable
will be used for colorization.