Joutsen Logging v0.5.0+22-gec3d058
Public Member Functions | Properties | List of all members
Joutsen.Logging.XmlFormatter Class Reference

A class that defines a Joutsen.Logging.IFormatter that formats log entries as XML file records. More...

Public Member Functions

 XmlFormatter (bool prettyPrint=false)
 Creates a new instance of the formatter. More...
 
string Format (LogRecord record)
 Creates a XML representation of the @paramref record. More...
 
string GetHeader (global::System.Text.Encoding encoding)
 Creates the XML declaration and the root element of the XML log. More...
 
string GetSeparator ()
 Creates a separator that is to be written between records. More...
 
string GetTail ()
 Closes the root element of the XML log. More...
 
- Public Member Functions inherited from Joutsen.Logging.Formatter
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...
 

Properties

bool IsPrettyPrinted [get]
 Determines if the output of this formatter is pretty printed with indentation and line breaks. More...
 

Detailed Description

A class that defines a Joutsen.Logging.IFormatter that formats log entries as XML file records.

Remarks
Creates entries for a XML document with <log> as the root element and each log entry as a <record> tag. The <record> tags contain the property values as sub elements. The created records are indented with two spaces for each level to improve readability.
Since
0.2.0
Examples\n\ref FormatterExamples

Constructor & Destructor Documentation

◆ XmlFormatter()

Joutsen.Logging.XmlFormatter.XmlFormatter ( bool  prettyPrint = false)

Creates a new instance of the formatter.

Parameters
IsPrettyPrintDetermines if the output should be pretty printed. Optional, default is false.
Returns
If @paramref prettyPrint is false all output will be in a single line, otherwise line breaks and indentation will be added to the output. The pretty print output is intended for human readability and should be avoided the file can be post processed to create smaller logs.

Member Function Documentation

◆ Format()

string Joutsen.Logging.XmlFormatter.Format ( LogRecord  record)

Creates a XML representation of the @paramref record.

Parameters
recordthe record to create a formatted string from
Returns
a XML-Sytem.String representation of the @paramref record

Implements Joutsen.Logging.Formatter.

◆ GetHeader()

string Joutsen.Logging.XmlFormatter.GetHeader ( global::System.Text.Encoding  encoding)

Creates the XML declaration and the root element of the XML log.

Parameters
encodinginformation about the encoding that will be used to write log entries @retruns a Sytem.String representing the XML declaration and the root element of the XML log

◆ GetSeparator()

string Joutsen.Logging.XmlFormatter.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

Implements Joutsen.Logging.Formatter.

◆ GetTail()

string Joutsen.Logging.XmlFormatter.GetTail ( )

Closes the root element of the XML log.

Returns
a Sytem.String representing the closing tag of the root element of the XML log

Implements Joutsen.Logging.Formatter.

Property Documentation

◆ IsPrettyPrinted

bool Joutsen.Logging.XmlFormatter.IsPrettyPrinted
get

Determines if the output of this formatter is pretty printed with indentation and line breaks.