# Poco

# class FormattingChannel

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

## Description

The FormattingChannel is a filter channel that routes a Message through a Formatter before passing it on to the destination channel.

## Inheritance

Direct Base Classes: Channel

All Base Classes: Channel, Configurable, RefCountedObject

## Member Summary

Member Functions: close, getChannel, getFormatter, log, open, setChannel, setFormatter, setProperty

Inherited Functions: close, duplicate, getProperty, log, open, referenceCount, release, setProperty

## Types Aliases

### Ptr

using Ptr = AutoPtr < FormattingChannel >;

## Constructors

### FormattingChannel

FormattingChannel();

Creates a FormattingChannel.

### FormattingChannel

FormattingChannel(
Formatter::Ptr pFormatter
);

Creates a FormattingChannel and attaches a Formatter.

### FormattingChannel

FormattingChannel(
Formatter::Ptr pFormatter,
Channel::Ptr pChannel
);

Creates a FormattingChannel and attaches a Formatter and a Channel.

## Destructor

### ~FormattingChannel

~FormattingChannel();

## Member Functions

### close

void close();

Closes the attached channel.

See also: Poco::Channel::close()

### getChannel

Channel::Ptr getChannel() const;

Returns the channel to which the formatted messages are passed on.

### getFormatter

Formatter::Ptr getFormatter() const;

Returns the Formatter used to format messages, which may be null.

### log

void log(
const Message & msg
);

Formats the given Message using the Formatter and passes the formatted message on to the destination Channel.

See also: Poco::Channel::log()

### open

void open();

Opens the attached channel.

See also: Poco::Channel::open()

### setChannel

void setChannel(
Channel::Ptr pChannel
);

Sets the destination channel to which the formatted messages are passed on.

### setFormatter

void setFormatter(
Formatter::Ptr pFormatter
);

Sets the Formatter used to format the messages before they are passed on. If null, the message is passed on unmodified.

### setProperty

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

Sets or changes a configuration property.

Only the "channel" and "formatter" properties are supported, which allow setting the target channel and formatter, respectively, via the LoggingRegistry. The "channel" and "formatter" properties are set-only.

Unsupported properties are passed to the attached Channel.

See also: Poco::Channel::setProperty()