ConcatenatingLogFormatter

open class ConcatenatingLogFormatter: LogFormatter

The ConcatenatingLogFormatter lets you combine the output of multiple LogFormatters by concatenating their output and returning the result.

  • The LogFormatters whose output will be concatenated.

    Declaration

    Swift

    open let formatters: [LogFormatter]
  • Determines the behavior of format(_:) when one of the receiver’s formatters returns nil. When false, if any formatter returns nil, it is simply excluded from the concatenation, but formatting continues. Unless none of the formatters returns a string, the receiver will always return a non-nil value. However, when hardFail is true, all of the formatters must return strings; if any formatter returns nil, the receiver also returns nil.

    Declaration

    Swift

    open let hardFail: Bool
  • Initializes a new ConcatenatingLogFormatter instance.

    Declaration

    Swift

    public init(formatters: [LogFormatter], hardFail: Bool = false)

    Parameters

    formatters

    The LogFormatters whose output will be concatenated.

    hardFail

    Determines the behavior of format(_:) when one of the receiver’s formatters returns nil. When false, if any formatter returns nil, it is simply excluded from the concatenation, but formatting continues. Unless none of the formatters returns a string, the receiver will always return a non-nil value. However, when hardFail is true, all of the formatters must return strings; if any formatter returns nil, the receiver also returns nil.

  • Formats the LogEntry by passing it to each of the receiver’s LogFormatters and concatenating the output.

    Declaration

    Swift

    open func format(_ entry: LogEntry)
            -> String?

    Parameters

    entry

    The LogEntry to be formatted.

    Return Value

    The formatted result, or nil if formatting failed according to the receiver’s hardFail property.