ConcatenatingLogFormatter
open class ConcatenatingLogFormatter: LogFormatter
The ConcatenatingLogFormatter
lets you combine the output of multiple
LogFormatter
s by concatenating their output and returning the result.
-
The
LogFormatter
s whose output will be concatenated.Declaration
Swift
open let formatters: [LogFormatter]
-
Determines the behavior of
format(_:)
when one of the receiver’sformatters
returnsnil
. Whenfalse
, if any formatter returnsnil
, it is simply excluded from the concatenation, but formatting continues. Unless none of theformatters
returns a string, the receiver will always return a non-nil
value. However, whenhardFail
istrue
, all of theformatters
must return strings; if any formatter returnsnil
, the receiver also returnsnil
.Declaration
Swift
open let hardFail: Bool
-
Initializes a new
ConcatenatingLogFormatter
instance.Declaration
Swift
public init(formatters: [LogFormatter], hardFail: Bool = false)
Parameters
formatters
The
LogFormatter
s whose output will be concatenated.hardFail
Determines the behavior of
format(_:)
when one of the receiver’sformatters
returnsnil
. Whenfalse
, if any formatter returnsnil
, it is simply excluded from the concatenation, but formatting continues. Unless none of theformatters
returns a string, the receiver will always return a non-nil
value. However, whenhardFail
istrue
, all of theformatters
must return strings; if any formatter returnsnil
, the receiver also returnsnil
. -
Formats the
LogEntry
by passing it to each of the receiver’sLogFormatter
s 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’shardFail
property.