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])
-
Default constructor for this writer
Declaration
Swift
public convenience init(format: OutputStreamFormatter = Default.format)
Parameters
format
An instance of an
OutputStreamFormatter
used to format the output before writing to the file.
-
Required write function for the logger
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
-
Defaults for init values
See moreDeclaration
Swift
public enum Default