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’stimestampproperty as a UNIX time value - The
severityof theLogEntryas a numeric value - The
Payloadof 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 moreFielddeclarations for theFieldBasedLogFormatter.Declaration
Swift
public enum Field -
Initializes the
FieldBasedLogFormatterto use the specified fields.Declaration
Swift
public init(fields: [Field])Parameters
fieldsThe
Fields that will be used by the receiver. -
Initializes the
FieldBasedLogFormatterto use the specified formatters.Declaration
Swift
public override init(formatters: [LogFormatter])Parameters
formattersThe
LogFormatters that will be used by the receiver.
View on GitHub
FieldBasedLogFormatter Class Reference