Apache log4cxx  Version 0.12.1
appenderskeleton.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _LOG4CXX_APPENDER_SKELETON_H
19 #define _LOG4CXX_APPENDER_SKELETON_H
20 
21 #if defined(_MSC_VER)
22  #pragma warning ( push )
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 #include <log4cxx/appender.h>
28 #include <log4cxx/layout.h>
30 #include <log4cxx/spi/filter.h>
31 #include <log4cxx/helpers/object.h>
32 #include <log4cxx/helpers/pool.h>
33 #include <log4cxx/level.h>
34 
35 namespace log4cxx
36 {
43 class LOG4CXX_EXPORT AppenderSkeleton :
44  public virtual Appender,
45  public virtual helpers::Object
46 {
47  protected:
51 
54 
58 
63 
67 
70 
74  bool closed;
75 
77  mutable log4cxx::shared_mutex mutex;
78 
84  virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) = 0;
85 
86  void doAppendImpl(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
87 
88  public:
93  LOG4CXX_CAST_ENTRY(spi::OptionHandler)
95 
97  AppenderSkeleton(const LayoutPtr& layout);
98 
103  void finalize();
104 
109  virtual void activateOptions(log4cxx::helpers::Pool& /* pool */) {}
110  virtual void setOption(const LogString& option, const LogString& value);
111 
115  void addFilter(const spi::FilterPtr& newFilter) ;
116 
117  public:
121  void clearFilters();
122 
128  {
129  return errorHandler;
130  }
131 
136  {
137  return headFilter;
138  }
139 
146  {
147  return headFilter;
148  }
149 
154  {
155  return layout;
156  }
157 
158 
163  {
164  return name;
165  }
166 
171  const LevelPtr& getThreshold() const
172  {
173  return threshold;
174  }
175 
181  bool isAsSevereAsThreshold(const LevelPtr& level) const;
182 
183 
189  virtual void doAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
190 
194  void setErrorHandler(const spi::ErrorHandlerPtr eh);
195 
202  void setLayout(const LayoutPtr& layout1)
203  {
204  this->layout = layout1;
205  }
206 
210  void setName(const LogString& name1)
211  {
212  this->name.assign(name1);
213  }
214 
215 
224  void setThreshold(const LevelPtr& threshold);
225 
226 }; // class AppenderSkeleton
227 } // namespace log4cxx
228 
229 #if defined(_MSC_VER)
230  #pragma warning ( pop )
231 #endif
232 
233 
234 #endif //_LOG4CXX_APPENDER_SKELETON_H
LevelPtr threshold
There is no level threshold filtering by default.
Definition: appenderskeleton.h:57
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:148
bool closed
Is this appender closed?
Definition: appenderskeleton.h:74
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
Implementation base class for all appenders.
Definition: appenderskeleton.h:43
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:27
log4cxx::shared_mutex mutex
Definition: appenderskeleton.h:77
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:37
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136
LogString name
Appenders are named.
Definition: appenderskeleton.h:53
spi::ErrorHandlerPtr errorHandler
It is assumed and enforced that errorHandler is never null.
Definition: appenderskeleton.h:62
const spi::ErrorHandlerPtr & getErrorHandler() const
Return the currently set spi::ErrorHandler for this Appender.
Definition: appenderskeleton.h:127
void setLayout(const LayoutPtr &layout1)
Set the layout for this appender.
Definition: appenderskeleton.h:202
LayoutPtr layout
The layout variable does not need to be set if the appender implementation has its own layout...
Definition: appenderskeleton.h:50
void setName(const LogString &name1)
Set the name of this Appender.
Definition: appenderskeleton.h:210
spi::FilterPtr headFilter
The first filter in the filter chain.
Definition: appenderskeleton.h:66
base class for java-like objects.
Definition: object.h:101
spi::FilterPtr tailFilter
The last filter in the filter chain.
Definition: appenderskeleton.h:69
LogString getName() const
Returns the name of this Appender.
Definition: appenderskeleton.h:162
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:47
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:55
std::shared_ptr< ErrorHandler > ErrorHandlerPtr
Definition: appender.h:43
Definition: pool.h:32
LayoutPtr getLayout() const
Returns the layout of this appender.
Definition: appenderskeleton.h:153
const LevelPtr & getThreshold() const
Returns this appenders threshold level.
Definition: appenderskeleton.h:171
std::shared_ptr< Filter > FilterPtr
Definition: appender.h:40
spi::FilterPtr getFilter() const
Returns the head Filter.
Definition: appenderskeleton.h:135
log4cxx::helpers::Pool pool
Definition: appenderskeleton.h:76
Definition: appender.h:32
std::basic_string< logchar > LogString
Definition: logstring.h:66
const spi::FilterPtr & getFirstFilter() const
Return the first filter in the filter chain for this Appender.
Definition: appenderskeleton.h:145