log4cpp 1.1

BufferingAppender.hh

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00003  * Copyright 2002, Bastiaan Bakker. All rights reserved.
00004  *
00005  * See the COPYING file for the terms of usage and distribution.
00006  */
00007 
00008 #if !defined(h_ebd0ee89_622d_4af1_9a9d_d0e057debe86)
00009 #define h_ebd0ee89_622d_4af1_9a9d_d0e057debe86
00010 
00011 #include <log4cpp/LayoutAppender.hh>
00012 #include <log4cpp/TriggeringEventEvaluator.hh>
00013 #include <list>
00014 #include <memory>
00015 
00016 namespace log4cpp
00017 {
00018    class LOG4CPP_EXPORT BufferingAppender : public LayoutAppender 
00019    {
00020       public:
00021          BufferingAppender(const std::string name, unsigned long max_size, std::auto_ptr<Appender> sink,
00022                            std::auto_ptr<TriggeringEventEvaluator> evaluator);
00023       
00024          virtual void close() { sink_->close(); }
00025          
00026          bool getLossy() const { return lossy_; }
00027          void setLossy(bool lossy) { lossy_ = lossy; }
00028 
00029       protected:
00030          virtual void _append(const LoggingEvent& event);
00031 
00032       private:
00033          typedef std::list<LoggingEvent> queue_t;
00034          
00035          queue_t queue_;
00036          unsigned long max_size_;
00037          std::auto_ptr<Appender> sink_;
00038          std::auto_ptr<TriggeringEventEvaluator> evaluator_;
00039          bool lossy_;
00040 
00041          void dump();
00042    };
00043 }
00044 
00045 #endif // h_ebd0ee89_622d_4af1_9a9d_d0e057debe86
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines