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
LogFormatter
that returns aLogEntry
‘sprocessName
property.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct ProcessNameLogFormatter: LogFormatter
-
A
See moreLogFilter
implementation that filters out anyLogEntry
with aLogSeverity
less than a specified value.Declaration
Swift
public struct LogSeverityFilter: LogFilter
-
The
OSLogRecorder
is an implemention of theLogRecorder
protocol that records log entries using the new unified logging system available as of iOS 10.0, macOS 10.12, tvOS 10.0, and watchOS 3.0.Unless a
See moreLogTypeTranslator
is specified during construction, theOSLogRecorder
will record log messages with anOSLogType
of.default
. This is consistent with the behavior ofNSLog()
.Declaration
Swift
public struct OSLogRecorder: LogRecorder
-
A
LogFormatter
that returns a 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
See moreLogFormatter
that returns the message content of aLogEntry
whosepayload
is a.value
value.Declaration
Swift
public struct PayloadValueLogFormatter: LogFormatter
-
A
See moreLogFormatter
that returns thecallingStackFrame
of aLogEntry
whosepayload
is.trace
.Declaration
Swift
public struct PayloadTraceLogFormatter: LogFormatter
-
A
See moreLogFormatter
that returns a string representation of aLogEntry
‘spayload
property.Declaration
Swift
public struct PayloadLogFormatter: LogFormatter
-
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
-
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 the string representation of aLogEntry
‘sprocessID
property.This is typically combined with other
See moreLogFormatter
s within aConcatenatingLogFormatter
.Declaration
Swift
public struct ProcessIDLogFormatter: 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 moreLogFormatter
that returns the message content of aLogEntry
whosepayload
is a.message
value.Declaration
Swift
public struct PayloadMessageLogFormatter: LogFormatter
-
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