log4cpp: log4cpp::StringQueueAppender Class Reference

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# log4cpp::StringQueueAppender Class Reference

This class puts log messages in an in-memory queue. More...

`#include <StringQueueAppender.hh>`

Inheritance diagram for log4cpp::StringQueueAppender:

[legend]
Collaboration diagram for log4cpp::StringQueueAppender:

[legend]
List of all members.

## Public Member Functions
| StringQueueAppender (const std::string &name)
virtual | ~StringQueueAppender ()
virtual bool | reopen ()
| Reopens the output destination of this Appender, e.g.
virtual void | close ()
| Release any resources allocated within the appender such as file handles, network connections, etc.
virtual size_t | queueSize () const
| Return the current size of the message queue.
virtual std::queue< std::string > & | getQueue ()
| Return the queue to which the Appends adds messages.
virtual const std::queue< std::string > & | getQueue () const
| Return the queue to which the Appends adds messages.
virtual std::string | popMessage ()
| Pop the oldest log message from the front of the queue.
## Protected Member Functions
virtual void | _append (const LoggingEvent &event)
| Appends the LoggingEvent to the queue.
## Protected Attributes
std::queue< std::string > | _queue

## Detailed Description

This class puts log messages in an in-memory queue.

Its primary use is in test cases, but it may be useful elsewhere as well.

Since:
  0.2.4

## Constructor & Destructor Documentation

log4cpp::StringQueueAppender::StringQueueAppender | ( | const std::string & | name | ) |

log4cpp::StringQueueAppender::~StringQueueAppender | ( |  | ) | `[virtual]`

## Member Function Documentation

bool log4cpp::StringQueueAppender::reopen | ( |  | ) | `[virtual]`

Reopens the output destination of this Appender, e.g.

the logfile or TCP socket.

Returns:
  false if an error occured during reopening, true otherwise.

Reimplemented from log4cpp::AppenderSkeleton.

void log4cpp::StringQueueAppender::close | ( |  | ) | `[virtual]`

Release any resources allocated within the appender such as file handles, network connections, etc.

Implements log4cpp::AppenderSkeleton.

size_t log4cpp::StringQueueAppender::queueSize | ( |  | ) | const`[virtual]`

Return the current size of the message queue.

Shorthand for getQueue().size().

Returns:
  the queue size

std::queue< std::string > & log4cpp::StringQueueAppender::getQueue | ( |  | ) | `[virtual]`

Return the queue to which the Appends adds messages.

Returns:
  the message queue

const std::queue< std::string > & log4cpp::StringQueueAppender::getQueue | ( |  | ) | const`[virtual]`

Return the queue to which the Appends adds messages.

Returns:
  the message queue

std::string log4cpp::StringQueueAppender::popMessage | ( |  | ) | `[virtual]`

Pop the oldest log message from the front of the queue.

Returns:
  the oldest log message

void log4cpp::StringQueueAppender::_append | ( | const LoggingEvent & | event | ) | `[protected, virtual]`

Appends the LoggingEvent to the queue.

Parameters:

  | event | the LoggingEvent to layout and append to the queue.

Implements log4cpp::AppenderSkeleton.

## Member Data Documentation

std::queue<std::string> log4cpp::StringQueueAppender::_queue`[protected]`

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

- StringQueueAppender.hh
- StringQueueAppender.cpp