ColorizingLogFormatter
public struct ColorizingLogFormatter: LogFormatter
Wraps another LogFormatter
and colorizes its output according to the
LogSeverity
of the LogEntry
being recorded.
-
The
LogFormatter
wrapped by the receiver.Declaration
Swift
public let formatter: LogFormatter
-
The
TextColorizer
used to apply color formatting to the output of the receiver’sformatter
.Declaration
Swift
public let colorizer: TextColorizer
-
The
ColorTable
used to supply foreground and background text color information.Declaration
Swift
public let colorTable: ColorTable
-
Initializes a new
ColorizingLogFormatter
instance.Declaration
Swift
public init(formatter: LogFormatter, colorizer: TextColorizer, colorTable: ColorTable? = nil)
Parameters
formatter
The
LogFormatter
whose output will be colorized by the receiver.colorizer
The
TextColorizer
that will be used to colorize the output offormatter
.colorTable
The
ColorTable
to use for supplying color information to theTextColorizer
. -
Formats the
LogEntry
by first passing it to theLogFormatter
used to construct the receiver. Then, if a non-nil
value is returned, the resulting string have color formatting codes applied to it using thecolorizer
andcolorTable
specified at instantiation.Declaration
Swift
public func format(_ entry: LogEntry) -> String?
Parameters
entry
The
LogEntry
to be formatted.Return Value
The formatted result, or
nil
if the receiver’sformatter
returnsnil
when attempting to formatentry
.