ConsoleWriter

public class ConsoleWriter : OutputStreamWriter

ConsoleWriter is the default Writer in TraceLog and writes to stdout.

This writer will be installed for you if you do not set any other writer’s at configuration time. Its a basic writer that can be used at any time that you want the output to go to the stdout.

Creating a ConsoleWriter is simple using the built in defaults.

    let writer = ConsoleWriter()

    TraceLog.configure(writers: [writer])

Output Format

Since ConsoleWriter is an instance of OutputStreamWriter it allows you to specify the format of the output with any instance of OutputStreamFormatter. The default format is TextFormat with the default TextFormat options. You can easily change the format by overriding the default on creation.

    let writer = ConsoleWriter(format: JSONFormat())

    TraceLog.configure(writers: [writer])

Initialization

OutputStreamWriter conformance

  • Required write function for the logger

    See also

    Writer for more information about the write function.

    See also

    ‘Writer.LogEntry’ for a complete definition of the loggable entry.

    See also

    FailureReason for failure return types.

    Declaration

    Swift

    public func write(_ entry: Writer.LogEntry) -> Result<Int, FailureReason>
  • OutputStreamFormatter being used for formating output.

    Declaration

    Swift

    public let format: OutputStreamFormatter

Default Values

  • Defaults for init values

    See more

    Declaration

    Swift

    public enum Default