00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <log4tango/Portability.hh>
00029 #include <string>
00030 #include <map>
00031 #include <set>
00032 #include <log4tango/Level.hh>
00033 #include <log4tango/Layout.hh>
00034 #include <log4tango/LoggingEvent.hh>
00035 #include <log4tango/threading/Threading.hh>
00036
00037 #ifndef _LOG4TANGO_APPENDER_H
00038 #define _LOG4TANGO_APPENDER_H
00039
00040 namespace log4tango {
00041
00042
00043
00044
00045 class LOG4TANGO_EXPORT Appender
00046 {
00047 friend class Logger;
00048
00049 protected:
00055 Appender (const std::string& name);
00056
00063 virtual void level_changed (Level::Value new_level);
00064
00065 public:
00069 virtual ~Appender ();
00070
00075 #if defined(APPENDERS_HAVE_LEVEL_THRESHOLD) || defined(APPENDERS_HAVE_FILTERS)
00076 int append (const LoggingEvent& event);
00077 #else
00078 inline int append (const LoggingEvent& event) {
00079 return _append(event);
00080 }
00081 #endif
00082
00088 virtual bool reopen (void);
00089
00094 virtual void close (void) = 0;
00095
00101 virtual bool requires_layout (void) const = 0;
00102
00106 virtual void set_layout (Layout* layout = 0) = 0;
00107
00111 inline const std::string& get_name (void) const {
00112 return _name;
00113 }
00114
00122 virtual bool is_valid (void) const;
00123
00124 #ifdef APPENDERS_HAVE_LEVEL_THRESHOLD
00125
00131 void set_level (Level::Value level);
00132
00137 Level::Value get_level (void) const;
00138 #endif // APPENDERS_HAVE_LEVEL_THRESHOLD
00139
00140 #ifdef APPENDERS_HAVE_FILTERS
00141
00144 virtual void set_filter (Filter* filter);
00145
00150 virtual Filter* get_filter (void);
00151 #endif // APPENDERS_HAVE_FILTERS
00152
00153 protected:
00159 virtual int _append(const LoggingEvent& event) = 0;
00160
00161 private:
00165 const std::string _name;
00166
00167 #ifdef APPENDERS_HAVE_LEVEL_THRESHOLD
00168
00171 Level::Value _level;
00172 #endif
00173
00174 #ifdef APPENDERS_HAVE_FILTERS
00175
00178 Filter* _filter;
00179 #endif
00180 };
00181
00182 }
00183
00184 #endif // _LOG4TANGO_APPENDER_H