Kea 2.7.0
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
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
27public:
28 LogBufferAddAfterFlush(const char* file, size_t line, const char* what) :
29 isc::Exception(file, line, what)
30 {}
31};
32
34typedef boost::shared_ptr<log4cplus::spi::InternalLoggingEvent> LogEventPtr;
35
39typedef std::pair<std::string, LogEventPtr> LevelAndEvent;
40
42typedef std::vector<LevelAndEvent> LogEventList;
43
65class 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
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
size_t getBufferSize() const
Returns the number of stored logging events.
virtual void append(const log4cplus::spi::InternalLoggingEvent &event)
void flush()
Flush the internal buffer.
virtual void close()
Close the appender.
LogBufferAddAfterFlush(const char *file, size_t line, const char *what)
std::pair< std::string, LogEventPtr > LevelAndEvent
Convenience typedef for a pair string/logeventptr, the string representing the logger level,...
std::vector< LevelAndEvent > LogEventList
Convenience typedef for a vector of LevelAndEvent instances.
boost::shared_ptr< log4cplus::spi::InternalLoggingEvent > LogEventPtr
Convenience typedef for a pointer to a log event.
Defines the logger used by the top-level component of kea-lfc.