Qore Logger Module Reference 0.6
|
Implements pattern parsing and substitution. More...
#include <Logger.qm.dox.h>
Public Member Methods | |
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... | |
Public Attributes | |
const | ESCAPE_CHAR = "%" |
format escape character | |
Private Member Methods | |
abstract *string | resolveField (auto data, string key, *string option) |
Returns a formatted string for an input pattern. More... | |
Private Attributes | |
list< auto > | parsedPattern |
parsed pattern; list elements may be strings or hashes | |
Private:Internal Attributes | |
string | origPattern |
pattern | |
Implements pattern parsing and substitution.
The pattern defines fields to be substituted with real values
The pattern format is:
When a word (i.e. longer than one char) key without curly brackets is not found then in the next step is resolved its first char, e.g. "%parchive"
the first step tries to resolve "parchive"
key and if not resolved the second step "p"
key. To parse in key if single step delimit a word from the next character, use curly brackets, i.e. empty option, e.g. "%p{}archive"
. If a key is not resolved then exception is raised.
The following table covers various modifiers and scenarios:
Format modifier | left justify | minimum width | maximum width | comment |
%20c | false | 20 | none | Left pad with spaces if the category name is less than 20 characters long |
%-20c | true | 20 | none | Right pad with spaces if the category name is less than 20 characters long |
%.30c | NA | none | 30 | Truncate from the beginning if the category name is longer than 30 characters |
%20.30c | false | 20 | 30 | Left pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning |
%-20.30c | true | 20 | 30 | Right pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning |
Logger::LoggerPattern::constructor | ( | string | pattern | ) |
Creates the object.
pattern | the logger pattern |
LOGGER-ERROR | when pattern is invalid |
string Logger::LoggerPattern::format | ( | auto | data | ) |
Formats the event record with the current pattern.
data | is passed to resolveField() |
LOGGER-ERROR | when a key is not resolved |
|
privatepure virtual |
Returns a formatted string for an input pattern.
data | input context reference data |
key | the format character |
option | the format option value, if any |
Implemented in Logger::LoggerAppenderFileRotate, Logger::LoggerAppenderFileRing, Logger::LoggerAppenderFileArchive, and Logger::LoggerLayoutPattern.
Logger::LoggerPattern::setPattern | ( | string | value | ) |
Sets the new pattern.
value | the logger pattern |
LOGGER-ERROR | when pattern is invalid |