Poco

class PatternFormatter

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: fmt, fmt0, format, getPriorityName, getProperty, setProperty

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

Constructors

PatternFormatter

PatternFormatter();

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

PatternFormatter

PatternFormatter(
    const std::string & format
);

Creates a PatternFormatter that uses the given format pattern.

Destructor

~PatternFormatter virtual

~PatternFormatter();

Destroys the 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.

See also: Poco::Formatter::format()

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.

See also: Poco::Formatter::getProperty()

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.

See also: Poco::Formatter::setProperty()

fmt protected static

static void fmt(
    std::string & str,
    int value
);

fmt protected static

static void fmt(
    std::string & str,
    int value,
    int width
);

fmt0 protected static

static void fmt0(
    std::string & str,
    int value,
    int width
);

getPriorityName protected static

static const std::string & getPriorityName(
    int
);

Returns a string for the given priority value.

Variables

PROP_PATTERN static

static const std::string PROP_PATTERN;

PROP_TIMES static

static const std::string PROP_TIMES;