Kea: buffer_appender_impl.h Source File

| Kea 3.2.0-git

buffer_appender_impl.h
Go to the documentation of this file.
1// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef LOG_BUFFER_H
8#define LOG_BUFFER_H
9
10#include <exceptions/exceptions.h>
11
12#include <log4cplus/logger.h>
13#include <log4cplus/spi/loggingevent.h>
14#include <boost/shared_ptr.hpp>
15
16namespace isc {
17namespace log {
18namespace internal {
19
26 class LogBufferAddAfterFlush : public isc::Exception {
27public:
28 LogBufferAddAfterFlush(const char* file, size_t line, const char* what) :
29 isc::Exception(file, line, what)
30 {}
31};
32
34 typedef boost::shared_ptr<log4cplus::spi::InternalLoggingEvent> LogEventPtr;
35
39 typedef std::pair<std::string, LogEventPtr> LevelAndEvent;
40
42 typedef std::vector<LevelAndEvent> LogEventList;
43
65 class BufferAppender : public log4cplus::Appender {
66public:
70 BufferAppender() : flushed_(false) {}
71
76 virtual ~BufferAppender();
77
81 virtual void close() {}
82
88 void flush();
89
93 size_t getBufferSize() const;
94
95protected:
96 virtual void append(const log4cplus::spi::InternalLoggingEvent& event);
97private:
99 void flushStdout();
100
101 LogEventList stored_;
102 bool flushed_;
103};
104
105} // end namespace internal
106} // end namespace log
107} // end namespace isc
108
109#endif // LOG_BUFFER_H
110
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition exceptions/exceptions.h:23
isc::Exception::Exception
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
Definition exceptions/exceptions.cc:17
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition exceptions/exceptions.cc:32
isc::log::internal::BufferAppender::getBufferSize
size_t getBufferSize() const
Returns the number of stored logging events.
Definition buffer_appender_impl.cc:68
isc::log::internal::BufferAppender::~BufferAppender
virtual ~BufferAppender()
Destructor.
Definition buffer_appender_impl.cc:20
isc::log::internal::BufferAppender::append
virtual void append(const log4cplus::spi::InternalLoggingEvent &event)
Definition buffer_appender_impl.cc:73
isc::log::internal::BufferAppender::flush
void flush()
Flush the internal buffer.
Definition buffer_appender_impl.cc:53
isc::log::internal::BufferAppender::close
virtual void close()
Close the appender.
Definition buffer_appender_impl.h:81
isc::log::internal::BufferAppender::BufferAppender
BufferAppender()
Constructor.
Definition buffer_appender_impl.h:70
isc::log::internal::LogBufferAddAfterFlush::LogBufferAddAfterFlush
LogBufferAddAfterFlush(const char *file, size_t line, const char *what)
Definition buffer_appender_impl.h:28
exceptions.h
isc::log::internal
Definition buffer_appender_impl.cc:18
isc::log::internal::LevelAndEvent
std::pair< std::string, LogEventPtr > LevelAndEvent
Convenience typedef for a pair string/logeventptr, the string representing the logger level,...
Definition buffer_appender_impl.h:39
isc::log::internal::LogEventList
std::vector< LevelAndEvent > LogEventList
Convenience typedef for a vector of LevelAndEvent instances.
Definition buffer_appender_impl.h:42
isc::log::internal::LogEventPtr
boost::shared_ptr< log4cplus::spi::InternalLoggingEvent > LogEventPtr
Convenience typedef for a pointer to a log event.
Definition buffer_appender_impl.h:34
isc::log
Definition buffer_appender_impl.cc:17
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18