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’s timestamp property as a UNIX time value
  • The severity of the LogEntry as a numeric value
  • The Payload of the LogEntry

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 Field declarations for the FieldBasedLogFormatter.

    See more

    Declaration

    Swift

    public enum Field
  • Initializes the FieldBasedLogFormatter to use the specified fields.

    Declaration

    Swift

    public init(fields: [Field])

    Parameters

    fields

    The Fields 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 LogFormatters that will be used by the receiver.