log4cpp  1.1.6
Appender.hh
Go to the documentation of this file.
1 /*
2  * Appender.hh
3  *
4  * Copyright 2000, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2000, Bastiaan Bakker. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #ifndef _LOG4CPP_APPENDER_HH
11 #define _LOG4CPP_APPENDER_HH
12 
13 #include <fcntl.h>
14 #include <log4cpp/Layout.hh>
15 #include <log4cpp/LoggingEvent.hh>
16 #include <log4cpp/Portability.hh>
17 #include <log4cpp/Priority.hh>
19 #include <map>
20 #include <set>
21 #include <stdarg.h>
22 #include <string>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <vector>
26 
27 namespace log4cpp {
29 
35  friend class Category;
36 
37  public:
44  static Appender* getAppender(const std::string& name);
45 
50  static bool reopenAll();
51 
56  static void closeAll();
57 
58  protected:
64  Appender(const std::string& name);
65 
66  public:
70  virtual ~Appender();
71 
76  virtual void doAppend(const LoggingEvent& event) = 0;
77 
83  virtual bool reopen() = 0;
84 
89  virtual void close() = 0;
90 
96  virtual bool requiresLayout() const = 0;
97 
102  virtual void setLayout(Layout* layout) = 0;
103 
108  inline const std::string& getName() const {
109  return _name;
110  };
111 
118  virtual void setThreshold(Priority::Value priority) = 0;
119 
124  virtual Priority::Value getThreshold() = 0;
125 
129  virtual void setFilter(Filter* filter) = 0;
130 
135  virtual Filter* getFilter() = 0;
136 
137  private:
138  typedef std::map<std::string, Appender*> AppenderMap;
139 
140  static AppenderMap& _getAllAppenders();
141  static void _deleteAllAppenders();
142  static void _deleteAllAppendersWOLock(std::vector<Appender*>& appenders);
143  static void _addAppender(Appender* appender);
144  static void _removeAppender(Appender* appender);
145 
146  const std::string _name;
147 
148  public:
150  public:
154  Appender::AppenderMap* _allAppenders;
159 
162  };
164  public:
167  };
168 
169  private:
170  static AppenderMapStorage& _appenderMapStorageInstance;
171  };
172 
177  typedef std::set<Appender*> AppenderSet;
178 
179 } // namespace log4cpp
180 
181 #endif // _LOG4CPP_APPENDER_HH
This is the central class in the log4j package.
Definition: Category.hh:32
Appender::AppenderMap * _allAppenders
single shared instance, nifty-counter defensed
Definition: Appender.hh:154
Users should extend this class to implement customized logging event filtering.
Definition: Filter.hh:49
Extend this abstract class to create your own log layout format.
Definition: Layout.hh:22
#define LOG4CPP_EXPORT
Definition: Export.hh:26
The top level namespace for all &#39;Log for C++&#39; types and classes.
Definition: AbortAppender.hh:16
The internal representation of logging events.
Definition: LoggingEvent.hh:32
int Value
The type of Priority Values.
Definition: Priority.hh:85
Implement this interface for your own strategies for printing log statements.
Definition: Appender.hh:34
Definition: Appender.hh:149
static Appender::AppenderMapStorageInitializer appenderMapStorageInitializer
static initializer for every translation unit
Definition: Appender.hh:176
Definition: PThreads.hh:28
std::set< Appender * > AppenderSet
Definition: Appender.hh:177
threading::Mutex _appenderMapMutex
mutex protecting map from multiple thread access
Definition: Appender.hh:158
const std::string & getName() const
Get the name of this appender.
Definition: Appender.hh:108