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’sformattersreturnsnil. Whenfalse, if any formatter returnsnil, it is simply excluded from the concatenation, but formatting continues. Unless none of theformattersreturns a string, the receiver will always return a non-nilvalue. However, whenhardFailistrue, all of theformattersmust return strings; if any formatter returnsnil, the receiver also returnsnil.Declaration
Swift
open let hardFail: Bool -
Initializes a new
ConcatenatingLogFormatterinstance.Declaration
Swift
public init(formatters: [LogFormatter], hardFail: Bool = false)Parameters
formattersThe
LogFormatters whose output will be concatenated.hardFailDetermines the behavior of
format(_:)when one of the receiver’sformattersreturnsnil. Whenfalse, if any formatter returnsnil, it is simply excluded from the concatenation, but formatting continues. Unless none of theformattersreturns a string, the receiver will always return a non-nilvalue. However, whenhardFailistrue, all of theformattersmust return strings; if any formatter returnsnil, the receiver also returnsnil. -
Formats the
LogEntryby passing it to each of the receiver’sLogFormatters and concatenating the output.Declaration
Swift
open func format(_ entry: LogEntry) -> String?Parameters
entryThe
LogEntryto be formatted.Return Value
The formatted result, or
nilif formatting failed according to the receiver’shardFailproperty.
View on GitHub
ConcatenatingLogFormatter Class Reference