Software Developer Kit (SDK)

Some use cases may require Writers or Formatters that are not already built-in so TraceLog allows you to write your own.

A custom endpoint writer can be created by implementing one of the writer protocols, Writer and OutputStreamWriter. Writer is the lowest level writer type which is suitable for writing any kind of writer required. The OutputStreamWriter is a higher level writer which inherits from Writer and is used to write to byte stream type endpoints. ConsoleWriter and FileWriter are examples of OutputStreamWriters.

The OutputStreamWriter protocol requires an OutputStreamFormatter which you can also create a custom implenentation of. Two are supplied with TraceLog, the TextFormat and the JSONFormat. Thee can be used as a reference for writing your own.

  • The Writer protocol defines the interface required when writing a log writer for the TraceLog system. Log writers are used to output all log messages to an output device like stdout, http endpoint, tcp/ip sockets, etc.

    There are no constructor/init requirements so any init method can be defined in your writer to initialize it prior to passing it to TraceLog.

    ConsoleWriter is a concrete implementation of the Writer protocol and can be used as a basic example of creating custom writers.

    See also

    ConsoleWriter for an example implementation.

    See also

    FileWriter for an example implementation.
    See more

    Declaration

    Swift

    public protocol Writer
  • A formatter type for formating the output of a OutputStreamWriter type.

    OutputStreamFormatter have one purpose in life, to convert a Writer.LogEntry into a formatted collection of bytes.

    See also

    TextFormat for concrete implementation of an OutputStreamFormatter.

    See also

    JSONFormat for concrete implementation of an OutputStreamFormatter.
    See more

    Declaration

    Swift

    public protocol OutputStreamFormatter