Joutsen Logging v0.5.0+22-gec3d058
Public Member Functions | List of all members
Joutsen.Logging.Formatter Interface Reference

Defines the interface for classes that determine the output format of log records. More...

Public Member Functions

String Format (LogRecord record)
 Creates a formated string representation of the @paramref record which can be written. More...
 
String GetHeader (Encoding encoding)
 Creates the header that is to be written before the first record is written. More...
 
String GetTail ()
 Creates additional information that is written after the last record. More...
 
String GetSeparator ()
 Creates a separator that is to be written between records. More...
 

Detailed Description

Defines the interface for classes that determine the output format of log records.

Remarks
The formatter is called before the log entry is written and provides a way to determine how a record is written. It is the formatters responsibility to determine which attributes of the log record are to be logged. The formatter and the Joutsen.Logging.IHandler need to be compatible. That means the formatter needs to create records the handler can write.
Since
0.2.0

Member Function Documentation

◆ Format()

String Joutsen.Logging.Formatter.Format ( LogRecord  record)

Creates a formated string representation of the @paramref record which can be written.

Parameters
recordthe record to create a formatted string from
Returns
a string representation of the log record

Implemented in Joutsen.Logging.CsvFormatter, Joutsen.Logging.JsonFormatter, Joutsen.Logging.SimpleFormatter, and Joutsen.Logging.XmlFormatter.

◆ GetHeader()

String Joutsen.Logging.Formatter.GetHeader ( Encoding  encoding)

Creates the header that is to be written before the first record is written.

Parameters
encodinginformation about the encoding that will be used to write log entries. This is just an information that can be written to the header if necessary. Ususally formatters do not need to encode their results because that is the handlers job.
Returns
a string representation of the header that is to be written
Remarks
The header is important for output formats like XML or CSV which would not be valid or hard to understand without header information.

◆ GetSeparator()

String Joutsen.Logging.Formatter.GetSeparator ( )

Creates a separator that is to be written between records.

Returns
a separator string that is to be written between records.
Remarks
The separator is written between records and not after the header or before the tail.
Since
0.3.0

Implemented in Joutsen.Logging.CsvFormatter, Joutsen.Logging.JsonFormatter, Joutsen.Logging.SimpleFormatter, and Joutsen.Logging.XmlFormatter.

◆ GetTail()

String Joutsen.Logging.Formatter.GetTail ( )

Creates additional information that is written after the last record.

Returns
A string representation of the footer that is to be written.
Remarks
The footer is important for output formats like XML which would not be valid without closing the root tag.

Implemented in Joutsen.Logging.CsvFormatter, Joutsen.Logging.JsonFormatter, Joutsen.Logging.SimpleFormatter, and Joutsen.Logging.XmlFormatter.