Structs
The following structs are available globally.
-
A
LogFormatter
that returns a string representation of the passed-inLogEntry
’sseverity
.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct SeverityLogFormatter: LogFormatter
-
A
LogFormatter
that returns a string representation of theLogEntry
’s call site, consisting of the last path component of thecallingFilePath
followed by thecallingFileLine
within that file.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct CallSiteLogFormatter: LogFormatter
-
LogChannel
instances provide the high-level interface for accepting log messages.They are responsible for converting log requests into
LogEntry
instances that they then pass along to their associatedLogReceptacle
s to perform the actual logging.
See moreLogChannel
s are provided as a convenience, exposed as static properties throughLog
. Use ofLogChannel
s and theLog
is not required for logging; you can also perform logging by creatingLogEntry
instances manually and passing them along to aLogReceptacle
.Declaration
Swift
public struct LogChannel
-
A
See moreLogFilter
implementation that filters out anyLogEntry
with aLogSeverity
less than a specified value.Declaration
Swift
public struct LogSeverityFilter: LogFilter
-
A
LogFormatter
that returns a hexadecimal string representation of aLogEntry
’scallingThreadID
.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct CallingThreadLogFormatter: LogFormatter
-
A
LogFormatter
that returns a string representation of aLogEntry
’stimestamp
property.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct TimestampLogFormatter: LogFormatter
-
A
LogFormatter
that returns a string representation of aLogEntry
’spayload
property.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct PayloadLogFormatter: LogFormatter
-
Wraps another
See moreLogFormatter
and colorizes its output according to theLogSeverity
of theLogEntry
being recorded.Declaration
Swift
public struct ColorizingLogFormatter: LogFormatter
-
A default implementation of the
See moreColorTable
protocol.Declaration
Swift
public struct DefaultColorTable: ColorTable
-
Represents a 3-component RGB color where each component is 8 bits. Used for specifying log output colors.
See moreDeclaration
Swift
public struct Color
-
Log
is the primary public API for CleanroomLogger.If you wish to send a message to the log, you do so by calling the appropriae function provided by the appropriate
LogChannel
given the importance of your message.There are five levels of severity at which log messages can be recorded. Each level is represented by a read-only static variable maintained by the
Log
:Log.error
— The highest severity; something has gone wrong and a fatal error may be imminentLog.warning
— Something appears amiss and might bear looking into before a larger problem arisesLog.info
— Something notable happened, but it isn’t anything to worry aboutLog.debug
— Used for debugging and diagnostic informationLog.verbose
- The lowest severity; used for detailed or frequently occurring debugging and diagnostic information
Each
LogChannel
can be used in one of three ways:- The
trace()
function records a short log message detailing the source file, source line, and function name of the caller. It is intended to be called with no arguments, as follows:
Log.debug?.trace()
- The
message()
function records a message specified by the caller:
Log.info?.message("The application has finished launching.")
message()
is intended to be called with a single parameter, the message string, as shown above. UnlikeNSLog()
, noprintf
-like functionality is provided; instead, use Swift string interpolation to construct parameterized messages.- Finally, the
value()
function records a string representation of an arbitraryAny
value:
Log.verbose?.value(delegate)
The
value()
function is intended to be called with a single parameter, of typeAny?
.The underlying logging implementation is responsible for converting this value into a string representation.
Note that some implementations may not be able to convert certain values into strings; in those cases, log requests may be silently ignored.
Enabling logging
By default, logging is disabled, meaning that none of the
Log
’s log channels have been populated. As a result, attempts to perform any logging will silently fail.It is the responsibility of the application developer to enable logging, which is done by calling the appropriate
See moreLog.enable()
function.Declaration
Swift
public struct Log
-
The
ASLLogRecorder
is an implemention of theLogRecorder
protocol that records log entries to the Apple System Log (ASL) facility.Unless a
See moreLogLevelTranslator
is specified during construction, theASLLogRecorder
will record log messages usingASL_LEVEL_WARNING
. This is consistent with the behavior ofNSLog()
.Declaration
Swift
public struct ASLLogRecorder: LogRecorder
-
A
LogFormatter
that returns thecallingStackFrame
property of aLogEntry
.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct StackFrameLogFormatter: LogFormatter
-
A
LogFormatter
that returns always returns a given literal string regardless of input.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct LiteralLogFormatter: LogFormatter
-
A
See moreTextColorizer
implementation that applies XcodeColors-compatible formatting to log messages.Declaration
Swift
public struct XcodeColorsTextColorizer: TextColorizer
-
A
LogFormatter
used to output field separator strings.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct DelimiterLogFormatter: LogFormatter