Structs
The following structs are available globally.
-
A
LogFormatterthat returns a string representation of the passed-inLogEntry‘sseverity.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct SeverityLogFormatter: LogFormatter
-
A
LogFormatterthat returns a string representation of theLogEntry‘s call site, consisting of the last path component of thecallingFilePathfollowed by thecallingFileLinewithin that file.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct CallSiteLogFormatter: LogFormatter
-
LogChannelinstances provide the high-level interface for accepting log messages.They are responsible for converting log requests into
LogEntryinstances that they then pass along to their associatedLogReceptacles to perform the actual logging.
See moreLogChannels are provided as a convenience, exposed as static properties throughLog. Use ofLogChannels and theLogis not required for logging; you can also perform logging by creatingLogEntryinstances manually and passing them along to aLogReceptacle.Declaration
Swift
public struct LogChannel
-
A
LogFormatterthat returns aLogEntry‘sprocessNameproperty.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct ProcessNameLogFormatter: LogFormatter
-
A
See moreLogFilterimplementation that filters out anyLogEntrywith aLogSeverityless than a specified value.Declaration
Swift
public struct LogSeverityFilter: LogFilter
-
The
OSLogRecorderis an implemention of theLogRecorderprotocol 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 moreLogTypeTranslatoris specified during construction, theOSLogRecorderwill record log messages with anOSLogTypeof.default. This is consistent with the behavior ofNSLog().Declaration
Swift
public struct OSLogRecorder: LogRecorder
-
A
LogFormatterthat returns a string representation of aLogEntry‘scallingThreadID.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct CallingThreadLogFormatter: LogFormatter
-
A
LogFormatterthat returns a string representation of aLogEntry‘stimestampproperty.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct TimestampLogFormatter: LogFormatter
-
A
See moreLogFormatterthat returns the message content of aLogEntrywhosepayloadis a.valuevalue.Declaration
Swift
public struct PayloadValueLogFormatter: LogFormatter
-
A
See moreLogFormatterthat returns thecallingStackFrameof aLogEntrywhosepayloadis.trace.Declaration
Swift
public struct PayloadTraceLogFormatter: LogFormatter
-
A
See moreLogFormatterthat returns a string representation of aLogEntry‘spayloadproperty.Declaration
Swift
public struct PayloadLogFormatter: LogFormatter
-
Logis 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
LogChannelgiven 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
LogChannelcan 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 arbitraryAnyvalue:
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
LogFormatterthat returns thecallingStackFrameproperty of aLogEntry.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct StackFrameLogFormatter: LogFormatter
-
A
LogFormatterthat returns the string representation of aLogEntry‘sprocessIDproperty.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct ProcessIDLogFormatter: LogFormatter
-
A
LogFormatterthat returns always returns a given literal string regardless of input.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct LiteralLogFormatter: LogFormatter
-
A
See moreLogFormatterthat returns the message content of aLogEntrywhosepayloadis a.messagevalue.Declaration
Swift
public struct PayloadMessageLogFormatter: LogFormatter
-
A
LogFormatterused to output field separator strings.This is typically combined with other
See moreLogFormatters within aConcatenatingLogFormatter.Declaration
Swift
public struct DelimiterLogFormatter: LogFormatter
View on GitHub
Structs Reference