00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _LOG4CPP_APPENDER_HH
00011 #define _LOG4CPP_APPENDER_HH
00012
00013 #include <string>
00014 #include <map>
00015 #include <set>
00016 #include <stdarg.h>
00017 #include <log4cpp/Portability.hh>
00018 #include <log4cpp/OstringStream.hh>
00019 #include <log4cpp/Priority.hh>
00020 #include <log4cpp/Layout.hh>
00021 #include <log4cpp/LoggingEvent.hh>
00022 #include <log4cpp/Filter.hh>
00023 #include <log4cpp/Log4cppCleanup.hh>
00024 #include <log4cpp/threading/Threading.hh>
00025
00026 namespace log4cpp {
00027 class LOG4CPP_EXPORT Category;
00028
00033 class LOG4CPP_EXPORT Appender {
00034 friend class log4cpp::Log4cppCleanup;
00035
00036 public:
00037
00044 static Appender* getAppender(const std::string& name);
00045
00050 static bool reopenAll();
00051
00056 static void closeAll();
00057
00058 protected:
00064 Appender(const std::string& name);
00065
00066 public:
00070 virtual ~Appender();
00071
00076 virtual void doAppend(const LoggingEvent& event) = 0;
00077
00083 virtual bool reopen() = 0;
00084
00089 virtual void close() = 0;
00090
00096 virtual bool requiresLayout() const = 0;
00097
00102 virtual void setLayout(Layout* layout) = 0;
00103
00108 inline const std::string& getName() const { return _name; };
00109
00116 virtual void setThreshold(Priority::Value priority) = 0;
00117
00122 virtual Priority::Value getThreshold() = 0;
00123
00127 virtual void setFilter(Filter* filter) = 0;
00128
00133 virtual Filter* getFilter() = 0;
00134
00135 private:
00136 typedef std::map<std::string, Appender*> AppenderMap;
00137
00138 static AppenderMap* _allAppenders;
00139 static threading::Mutex _appenderMapMutex;
00140
00141 static AppenderMap& _getAllAppenders();
00142 static void _deleteAllAppenders();
00143 static void _addAppender(Appender* appender);
00144 static void _removeAppender(Appender* appender);
00145
00146 #ifdef LOG4CPP_USE_CLEANUP
00147 static Log4cppCleanup& _fuckinDummy;
00148 #endif
00149 const std::string _name;
00150 };
00151
00152 typedef std::set<Appender *> AppenderSet;
00153 }
00154
00155 #endif // _LOG4CPP_APPENDER_HH