Poco

class AsyncChannel

File Information

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

Description

A channel uses a separate thread for logging.

Using this channel can help to improve the performance of applications that produce huge amounts of log messages or that write log messages to multiple channels simultaneously.

All log messages are put into a queue and this queue is then processed by a separate thread.

Inheritance

Direct Base Classes: Channel, Runnable

All Base Classes: Channel, Configurable, RefCountedObject, Runnable

Member Summary

Member Functions: close, getChannel, log, open, run, setChannel, setPriority, setProperty

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

Types Aliases

Ptr

using Ptr = AutoPtr < AsyncChannel >;

Constructors

AsyncChannel

AsyncChannel(
    Channel::Ptr pChannel = 0,
    Thread::Priority prio = Thread::PRIO_NORMAL
);

Creates the AsyncChannel and connects it to the given channel.

Destructor

~AsyncChannel protected virtual

~AsyncChannel();

Member Functions

close virtual

void close();

Closes the channel and stops the background logging thread.

getChannel

Channel::Ptr getChannel() const;

Returns the target channel.

log virtual

void log(
    const Message & msg
);

Queues the message for processing by the background thread.

open virtual

void open();

Opens the channel and creates the background logging thread.

setChannel

void setChannel(
    Channel::Ptr pChannel
);

Connects the AsyncChannel to the given target channel. All messages will be forwarded to this channel.

setProperty virtual

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

Sets or changes a configuration property.

The "channel" property allows setting the target channel via the LoggingRegistry. The "channel" property is set-only.

The "priority" property allows setting the thread priority. The following values are supported:

  • lowest
  • low
  • normal (default)
  • high
  • highest

The "priority" property is set-only.

The "queueSize" property allows to limit the number of messages in the queue. If the queue is full and new messages are logged, these are dropped until the queue has free capacity again. The number of dropped messages is recorded, and a log message indicating the number of dropped messages will be generated when the queue has free capacity again. In addition to an unsigned integer specifying the size, this property can have the values "none" or "unlimited", which disable the queue size limit. A size of 0 also removes the limit.

The "queueSize" property is set-only.

run protected virtual

void run();

setPriority protected

void setPriority(
    const std::string & value
);