| Qore logger_bin Module 2.0.0

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Qore::Logger::LoggerLayoutPattern Class Reference

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

`#include <QC_LoggerLayoutPattern.dox.h>`

Inheritance diagram for Qore::Logger::LoggerLayoutPattern:

## Public Member Functions
| constructor (string pattern="%r [%t] %p %c - %m%n")
| Creates the object.
string | format (LoggerEvent event)
| Returns a formatted string for an input pattern.
Public Member Functions inherited from Qore::Logger::LoggerLayout
abstract string | format (LoggerEvent event)
| Returns a formatted string for an input pattern.
Public Member Functions inherited from Qore::Logger::LoggerPattern
| constructor (string pattern)
| Creates the object.
string | format (auto data)
| Formats the event record with the current pattern.
list< auto > | getParsedPattern ()
| Returns the parsed pattern list.
string | getPattern ()
| Returns the current pattern.
| setPattern (string pattern)
| Sets the new pattern.

## Static Public Member Functions
static string | getLineDelimiter ()
| Returns the line delimiter used on the current OS.

## Protected Member Functions
*string | resolveField (auto event, string key, *string option)
| Returns the value corresponding to a particular key.
Protected Member Functions inherited from Qore::Logger::LoggerPattern
abstract *string | resolveField (auto data, string key, *string option)
| Returns a formatted string for an input 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
`%h` | Used to output the hostname where the logging event was generated
`%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
`%P` | Used to output the PID where the logging event was generated
`%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()

Qore::Logger::LoggerLayoutPattern::constructor | ( | string | pattern = "%r [%t] %p %c - %m%n" | ) |

Creates the object.

Parameters

  pattern | the logger layout pattern

## ◆ format()

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

Returns a formatted string for an input pattern.

Format event record

## ◆ resolveField()

*string Qore::Logger::LoggerLayoutPattern::resolveField | ( | auto | event,
|  | string | key,
|  | *string | option )
| protected

Returns the value corresponding to a particular key.

Parameters

  event | (LoggerEvent)
  key | the single-character formatting code
  option | optional supporting information for key

Exceptions

  UNSUPPORTED-EVENT-TYPE | thrown if the event is not a LoggerEvent object

The documentation for this class was generated from the following file:

- modules/logger_bin/src/QC_LoggerLayoutPattern.dox.h