The following structs are available globally.

  • 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 associated LogReceptacles to perform the actual logging.

    LogChannels are provided as a convenience, exposed as static properties through Log. Use of LogChannels and the Log is not required for logging; you can also perform logging by creating LogEntry instances manually and passing them along to a LogReceptacle.

    See more



    public struct LogChannel
  • The OSLogRecorder is an implemention of the LogRecorder 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 LogTypeTranslator is specified during construction, the OSLogRecorder will record log messages with an OSLogType of .default. This is consistent with the behavior of NSLog().

    See more



    public struct OSLogRecorder: LogRecorder
  • Log

    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 imminent

    • Log.warning — Something appears amiss and might bear looking into before a larger problem arises

    • — 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

    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:
    • The message() function records a message specified by the caller:"The application has finished launching.")

    message() is intended to be called with a single parameter, the message string, as shown above. Unlike NSLog(), no 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 Any value:

    The value() function is intended to be called with a single parameter, of type Any?.

    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 Log.enable() function.

    See more



    public struct Log
  • Represents an entry to be written to the log.

    See more



    public struct LogEntry