FieldBasedLogFormatter
open class FieldBasedLogFormatter: ConcatenatingLogFormatter
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
’stimestamp
property as a UNIX time value - The
severity
of theLogEntry
as a numeric value - The
Payload
of theLogEntry
You could do this by constructing a FieldBasedLogFormatter
as follows:
let formatter = FieldBasedLogFormatter(fields: [.Timestamp(.UNIX),
.Delimiter(.Tab),
.Severity(.Numeric),
.Delimiter(.Tab),
.Payload])
-
The individual
See moreField
declarations for theFieldBasedLogFormatter
.Declaration
Swift
public enum Field
-
Initializes the
FieldBasedLogFormatter
to use the specified fields.Declaration
Swift
public init(fields: [Field])
Parameters
fields
The
Field
s that will be used by the receiver. -
Initializes the
FieldBasedLogFormatter
to use the specified formatters.Declaration
Swift
public override init(formatters: [LogFormatter])
Parameters
formatters
The
LogFormatter
s that will be used by the receiver.