HeliumStreamLogger

public class HeliumStreamLogger<OutputStream: TextOutputStream> : HeliumLogger

A HeliumLogger, that prints to a TextOutputStream.

  • Create a HeliumStreamLogger instance and set it up as the logger used by the LoggerAPI protocol.

    Usage Example:

    This example shows logging to stderr.

    struct StandardError: TextOutputStream {
        func write(_ text: String) {
            guard let data = text.data(using: String.Encoding.utf8) else {
              return
            }
            FileHandle.standardError.write(data)
        }
    }
    
    let se = StandardError()
    HeliumStreamLogger.use(outputStream: se)
    

    Declaration

    Swift

    public static func use(_ type: LoggerMessageType = .verbose, outputStream: OutputStream)

    Parameters

    type

    The most detailed message type (LoggerMessageType) to see in the output of the logger. Defaults to verbose.

    outputStream

    The stream to send the output of the logger to.

  • Prevent the user accidentally invoking the use() function of the superclass. Prints an error message, stating that you should call use(_:outputStream:), no logging is enabled.

    Declaration

    Swift

    override public class func use(_ type: LoggerMessageType = .verbose)

    Parameters

    type

    The most detailed message type (LoggerMessageType) to see in the output of the logger. Default to verbose.

  • Create a HeliumStreamLogger instance.

    Declaration

    Swift

    public init (_ type: LoggerMessageType = .verbose, outputStream: OutputStream)

    Parameters

    type

    The most detailed message type (LoggerMessageType) to see in the output of the logger. Defaults to verbose.

    outputStream

    The stream to send the output of the logger to.