Qore Logger Module Reference  0.1.1
Logger::LoggerLayoutPattern Class Reference

Implements the formatting of LoggerEvent objects with a pattern. More...

Inheritance diagram for Logger::LoggerLayoutPattern:

Public Member Methods

 constructor (string n_pattern=DEFAULT_PATTERN)
 Creates the object. More...
string format (LoggerEvent event)
 Formats an event record. More...
- Public Member Methods inherited from Logger::LoggerPattern
 constructor (string pattern)
 Creates the object. More...
string format (auto data)
 Formats the event record with the current pattern. More...
string getPattern ()
 Returns the current pattern.
 setPattern (string value)
 Sets the new pattern. More...

Static Public Member Methods

static string getLineDelimiter ()
 Returns the line delimiter used on the current OS.

Public Attributes

 default date format
const DEFAULT_PATTERN = "%r [%t] %p %c - %m%n"
 default layout pattern
- Public Attributes inherited from Logger::LoggerPattern
const ESCAPE_CHAR = "%"
 format escape character

Private Member Methods

*string resolveField (auto event, string key, *string option)
 Returns the value corresponding to a particular key. More...

Additional Inherited Members

- Private Attributes inherited from Logger::LoggerPattern
list parsedPattern
 parsed pattern

Detailed Description

Implements the formatting of LoggerEvent objects with a pattern.

The LoggerLayoutPattern lets the user specify the output format according to conversion patterns similar to the sprintf() function.

The following table explains the characters used in LoggerPattern and all other characters that you can use in your custom pattern:

Conversion character Meaning
c Used to output the category of the logging event, i.e. logger name
C Used to output the class name of the caller issuing the logging request, i.e. logger class name
d Used to output the date of the logging event using format_date. Option may specify date format, e.g. "%d{DD.MM.YYYY HH:mm:SS}"
E Used to output the environment variable with name given by option, e.g. "%E{HOME}"
F Used to output the file name where the logging request was issued
l Used to output location information of the caller which generated the logging event, i.e. "file:line [function()]"
L Used to output the line number from where the logging request was issued, option may specify sprintf() format, e.g. "%.3d"
m Used to output the application supplied message associated with the logging event
M Used to output the method name where the logging request was issued
n Outputs the platform dependent line separator character or characters
p Used to output the priority of the logging event
r Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event, option may specify sprintf() format, e.g. "%.3d"
t Used to output the thread id that generated the logging event, option may specify sprintf() format, e.g. "%.3d"
u Used to output logging event unique id, option may specify sprintf() format, e.g. "%.3d"
x Used to output exception string using Util::get_exception_string()
% The literal percent sign. "%%" will print a "%" sign

For example, the LoggerLayoutPattern with the conversion pattern "%r [%t] %-5p %c - %m%n" will output something like:

        176 [23] INFO  MyLogger - New record created

Member Function Documentation

◆ constructor()

Logger::LoggerLayoutPattern::constructor ( string  n_pattern = DEFAULT_PATTERN)

Creates the object.

n_patternthe logger layout pattern

◆ format()

string Logger::LoggerLayoutPattern::format ( LoggerEvent  event)

Formats an event record.

eventthe event to format
a formatted string for the event

Implements Logger::LoggerLayout.

◆ resolveField()

*string Logger::LoggerLayoutPattern::resolveField ( auto  event,
string  key,
*string  option 

Returns the value corresponding to a particular key.

keythe single-character formatting code
optionoptional supporting information for key

Implements Logger::LoggerPattern.