Apache log4cxx  Version 0.11.0
appenderskeleton.h
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>
29 #include <log4cxx/spi/errorhandler.h>
30 #include <log4cxx/spi/filter.h>
31 #include <log4cxx/helpers/objectimpl.h>
32 #include <log4cxx/helpers/mutex.h>
33 #include <log4cxx/helpers/pool.h>
34 #include <log4cxx/level.h>
35 
36 
37 namespace log4cxx
38 {
45 class LOG4CXX_EXPORT AppenderSkeleton :
46  public virtual Appender,
47  public virtual helpers::ObjectImpl
48 {
49  protected:
53 
55  LogString name;
56 
60 
65 
69 
72 
76  bool closed;
77 
79  mutable SHARED_MUTEX mutex;
80 
86  virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) = 0;
87 
88  void doAppendImpl(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
89 
90  public:
91  DECLARE_ABSTRACT_LOG4CXX_OBJECT(AppenderSkeleton)
92  BEGIN_LOG4CXX_CAST_MAP()
93  LOG4CXX_CAST_ENTRY(AppenderSkeleton)
94  LOG4CXX_CAST_ENTRY(Appender)
95  LOG4CXX_CAST_ENTRY(spi::OptionHandler)
96  END_LOG4CXX_CAST_MAP()
97 
99  AppenderSkeleton(const LayoutPtr& layout);
100 
101  void addRef() const;
102  void releaseRef() const;
103 
108  void finalize();
109 
114  virtual void activateOptions(log4cxx::helpers::Pool& /* pool */) {}
115  virtual void setOption(const LogString& option, const LogString& value);
116 
120  void addFilter(const spi::FilterPtr& newFilter) ;
121 
122  public:
126  void clearFilters();
127 
133  {
134  return errorHandler;
135  }
136 
141  {
142  return headFilter;
143  }
144 
151  {
152  return headFilter;
153  }
154 
159  {
160  return layout;
161  }
162 
163 
167  LogString getName() const
168  {
169  return name;
170  }
171 
176  const LevelPtr& getThreshold() const
177  {
178  return threshold;
179  }
180 
186  bool isAsSevereAsThreshold(const LevelPtr& level) const;
187 
188 
194  virtual void doAppend(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool);
195 
199  void setErrorHandler(const spi::ErrorHandlerPtr& eh);
200 
207  void setLayout(const LayoutPtr& layout1)
208  {
209  this->layout = layout1;
210  }
211 
215  void setName(const LogString& name1)
216  {
217  this->name.assign(name1);
218  }
219 
220 
229  void setThreshold(const LevelPtr& threshold);
230 
231 }; // class AppenderSkeleton
232 } // namespace log4cxx
233 
234 #if defined(_MSC_VER)
235  #pragma warning ( pop )
236 #endif
237 
238 
239 #endif //_LOG4CXX_APPENDER_SKELETON_H
LevelPtr threshold
There is no level threshold filtering by default.
Definition: appenderskeleton.h:59
bool closed
Is this appender closed?
Definition: appenderskeleton.h:76
Implementation base class for all appenders.
Definition: appenderskeleton.h:45
LogString name
Appenders are named.
Definition: appenderskeleton.h:55
spi::ErrorHandlerPtr errorHandler
It is assumed and enforced that errorHandler is never null.
Definition: appenderskeleton.h:64
const spi::ErrorHandlerPtr & getErrorHandler() const
Return the currently set spi::ErrorHandler for this Appender.
Definition: appenderskeleton.h:132
void setLayout(const LayoutPtr &layout1)
Set the layout for this appender.
Definition: appenderskeleton.h:207
LayoutPtr layout
The layout variable does not need to be set if the appender implementation has its own layout...
Definition: appenderskeleton.h:52
void setName(const LogString &name1)
Set the name of this Appender.
Definition: appenderskeleton.h:215
Implementation class for Object.
Definition: objectimpl.h:28
spi::FilterPtr headFilter
The first filter in the filter chain.
Definition: appenderskeleton.h:68
spi::FilterPtr tailFilter
The last filter in the filter chain.
Definition: appenderskeleton.h:71
LogString getName() const
Returns the name of this Appender.
Definition: appenderskeleton.h:167
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:56
Definition: pool.h:32
LayoutPtr getLayout() const
Returns the layout of this appender.
Definition: appenderskeleton.h:158
const LevelPtr & getThreshold() const
Returns this appenders threshold level.
Definition: appenderskeleton.h:176
spi::FilterPtr getFilter() const
Returns the head Filter.
Definition: appenderskeleton.h:140
Definition: appender.h:33
const spi::FilterPtr & getFirstFilter() const
Return the first filter in the filter chain for this Appender.
Definition: appenderskeleton.h:150