# BufferingAppender.hh

Go to the documentation of this file.

    00001 #if !defined(h_ebd0ee89_622d_4af1_9a9d_d0e057debe86)
    00002 #define h_ebd0ee89_622d_4af1_9a9d_d0e057debe86
    00003
    00004 #include <log4cpp/LayoutAppender.hh>
    00005 #include <log4cpp/TriggeringEventEvaluator.hh>
    00006 #include <list>
    00007 #include <memory>
    00008
    00009 namespace log4cpp
    00010 {
    00011    class LOG4CPP_EXPORT BufferingAppender : public LayoutAppender
    00012    {
    00013       public:
    00014          BufferingAppender(const std::string name, unsigned long max_size, std::auto_ptr<Appender> sink,
    00015                            std::auto_ptr<TriggeringEventEvaluator> evaluator);
    00016
    00017          virtual void close() { sink_->close(); }
    00018
    00019          bool getLossy() const { return lossy_; }
    00020          void setLossy(bool lossy) { lossy_ = lossy; }
    00021
    00022       protected:
    00023          virtual void _append(const LoggingEvent& event);
    00024
    00025       private:
    00026          typedef std::list<LoggingEvent> queue_t;
    00027
    00028          queue_t queue_;
    00029          unsigned long max_size_;
    00030          std::auto_ptr<Appender> sink_;
    00031          std::auto_ptr<TriggeringEventEvaluator> evaluator_;
    00032          bool lossy_;
    00033
    00034          void dump();
    00035    };
    00036 }
    00037
    00038 #endif // h_ebd0ee89_622d_4af1_9a9d_d0e057debe86