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 OutputStreamWriter
s.
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.Declaration
Swift
public protocol Writer
-
A higher level Writer interface that specifically writes to an
OutputStream
and it’s output format can be controlled by anOutputStreamFormatter
.See also
OutputStreamFormatter
for more information about formatters for the output.See also
ConsoleWriter
for an example implementation.See also
FileWriter
for an example implementation.Declaration
Swift
public protocol OutputStreamWriter : Writer
-
A formatter type for formating the output of a
OutputStreamWriter
type.OutputStreamFormatter have one purpose in life, to convert a
See moreWriter.LogEntry
into a formatted collection of bytes.Declaration
Swift
public protocol OutputStreamFormatter