Class Poco::PatternFormatter (original) (raw)

Library: Foundation
Package: Logging
Header: Poco/PatternFormatter.h

Description

This Formatter allows for custom formatting of log messages based on format patterns.

The format pattern is used as a template to format the message and is copied character by character except for the following special characters, which are replaced by the corresponding value.

Inheritance

Direct Base Classes: Formatter

All Base Classes: Configurable, Formatter, RefCountedObject

Member Summary

Member Functions: format, getPriorityName, getProperty, setProperty

Inherited Functions: duplicate, format, getProperty, referenceCount, release, setProperty

Types Aliases

Ptr

using Ptr = AutoPtr < PatternFormatter >;

Constructors

PatternFormatter

PatternFormatter();

Creates a PatternFormatter. The format pattern must be specified with a call to setProperty.

PatternFormatter

PatternFormatter(
const std::string & format
);

Destructor

~PatternFormatter virtual

~PatternFormatter();

Member Functions

format virtual

void format(
const Message & msg,
std::string & text
);

Formats the message according to the specified format pattern and places the result in text.

getProperty virtual

std::string getProperty(
const std::string & name
) const;

Returns the value of the property with the given name or throws a PropertyNotSupported exception if the given name is not recognized.

setProperty virtual

void setProperty(
const std::string & name,
const std::string & value
);

Sets the property with the given name to the given value.

The following properties are supported:

If any other property name is given, a PropertyNotSupported exception is thrown.

getPriorityName protected

const std::string & getPriorityName(
int
);

Returns a string for the given priority value.

Variables

PROP_PATTERN static

static const std::string PROP_PATTERN;

PROP_PRIORITY_NAMES static

static const std::string PROP_PRIORITY_NAMES;

PROP_TIMES static

static const std::string PROP_TIMES;