The following structs are available globally.
public struct CallSiteLogFormatter: LogFormatter
LogChannelinstances provide the high-level interface for accepting log messages.
LogChannels are provided as a convenience, exposed as static properties through
Log. Use of
LogChannels and the
Logis not required for logging; you can also perform logging by creating
LogEntryinstances manually and passing them along to a
public struct LogChannel
OSLogRecorderis an implemention of the
LogRecorderprotocol 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 aSee more
LogTypeTranslatoris specified during construction, the
OSLogRecorderwill record log messages with an
.default. This is consistent with the behavior of
public struct OSLogRecorder: LogRecorder
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.error— The highest severity; something has gone wrong and a fatal error may be imminent
Log.warning— Something appears amiss and might bear looking into before a larger problem arises
Log.info— Something notable happened, but it isn’t anything to worry about
Log.debug— Used for debugging and diagnostic information
Log.verbose- The lowest severity; used for detailed or frequently occurring debugging and diagnostic information
LogChannelcan be used in one of three ways:
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:
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. Unlike
printf-like functionality is provided; instead, use Swift string interpolation to construct parameterized messages.
- Finally, the
value()function records a string representation of an arbitrary
value()function is intended to be called with a single parameter, of type
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.
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 appropriateSee more
public struct Log