Kea  2.3.2-git
isc::log::internal::BufferAppender Class Reference

Buffering Logger Appender. More...

#include <buffer_appender_impl.h>

+ Inheritance diagram for isc::log::internal::BufferAppender:

Public Member Functions

 BufferAppender ()
 Constructor. More...
 
virtual ~BufferAppender ()
 Destructor. More...
 
virtual void close ()
 Close the appender. More...
 
void flush ()
 Flush the internal buffer. More...
 
size_t getBufferSize () const
 Returns the number of stored logging events. More...
 

Protected Member Functions

virtual void append (const log4cplus::spi::InternalLoggingEvent &event)
 

Detailed Description

Buffering Logger Appender.

This class can be set as an Appender for log4cplus loggers, and is used to store logging events; it simply keeps any event that is passed to append(), and will replay them to the logger that they were originally created for when flush() is called.

The idea is that initially, a program may want to do some logging, but does not know where to yet (for instance because it has yet to read and parse its configuration). Any log messages before this time would normally go to some default (say, stdout), and be lost in the real logging destination. By buffering them (and flushing them once the logger has been configured), these log messages are kept in a consistent place, and are not lost.

Given this goal, this class has an extra check; it will raise an exception if append() is called after flush().

If the BufferAppender instance is destroyed before being flushed, it will dump any event it has left to stdout.

Definition at line 65 of file buffer_appender_impl.h.

Constructor & Destructor Documentation

◆ BufferAppender()

isc::log::internal::BufferAppender::BufferAppender ( )
inline

Constructor.

Constructs a BufferAppender that buffers log evens

Definition at line 70 of file buffer_appender_impl.h.

◆ ~BufferAppender()

isc::log::internal::BufferAppender::~BufferAppender ( )
virtual

Destructor.

Any remaining events are flushed to stdout (there should only be any events remaining if flush() was never called)

Definition at line 20 of file buffer_appender_impl.cc.

Member Function Documentation

◆ append()

void isc::log::internal::BufferAppender::append ( const log4cplus::spi::InternalLoggingEvent &  event)
protectedvirtual

Definition at line 75 of file buffer_appender_impl.cc.

References isc_throw.

◆ close()

virtual void isc::log::internal::BufferAppender::close ( )
inlinevirtual

Close the appender.

This class has no specialized handling for this method

Definition at line 81 of file buffer_appender_impl.h.

◆ flush()

void isc::log::internal::BufferAppender::flush ( )

Flush the internal buffer.

Events that have been stored (after calls to append() are replayed to the logger. Should only be called after new appenders have been set to the logger.

Definition at line 54 of file buffer_appender_impl.cc.

References isc::asiodns::logger.

Referenced by isc::log::LoggerManagerImpl::reset().

◆ getBufferSize()

size_t isc::log::internal::BufferAppender::getBufferSize ( ) const

Returns the number of stored logging events.

Mainly useful for testing

Definition at line 70 of file buffer_appender_impl.cc.


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