Apache log4cxx Version 0.13.0
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>
33#include <log4cxx/level.h>
34
35namespace log4cxx
36{
43class 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 std::recursive_mutex mutex;
78
84 virtual void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) = 0;
85
87
88 public:
93 LOG4CXX_CAST_ENTRY(spi::OptionHandler)
95
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:
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
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
Implementation base class for all appenders.
Definition: appenderskeleton.h:46
spi::ErrorHandlerPtr errorHandler
It is assumed and enforced that errorHandler is never null.
Definition: appenderskeleton.h:62
LayoutPtr layout
The layout variable does not need to be set if the appender implementation has its own layout.
Definition: appenderskeleton.h:50
void setErrorHandler(const spi::ErrorHandlerPtr eh)
Set the ErrorHandler for this Appender.
LevelPtr threshold
There is no level threshold filtering by default.
Definition: appenderskeleton.h:57
virtual void setOption(const LogString &option, const LogString &value)
Set option to value.
void addFilter(const spi::FilterPtr &newFilter)
Add a filter to end of the filter list.
bool closed
Is this appender closed?
Definition: appenderskeleton.h:74
const spi::FilterPtr & getFirstFilter() const
Return the first filter in the filter chain for this Appender.
Definition: appenderskeleton.h:145
LogString name
Appenders are named.
Definition: appenderskeleton.h:53
LogString getName() const
Returns the name of this Appender.
Definition: appenderskeleton.h:162
spi::FilterPtr getFilter() const
Returns the head Filter.
Definition: appenderskeleton.h:135
virtual void append(const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)=0
Subclasses of AppenderSkeleton should implement this method to perform actual logging.
spi::FilterPtr headFilter
The first filter in the filter chain.
Definition: appenderskeleton.h:66
void setLayout(const LayoutPtr &layout1)
Set the layout for this appender.
Definition: appenderskeleton.h:202
void clearFilters()
Clear the filters chain.
const spi::ErrorHandlerPtr & getErrorHandler() const
Return the currently set spi::ErrorHandler for this Appender.
Definition: appenderskeleton.h:127
void setThreshold(const LevelPtr &threshold)
Set the threshold level.
bool isAsSevereAsThreshold(const LevelPtr &level) const
Check whether the message level is below the appender's threshold.
void doAppendImpl(const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
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
virtual void doAppend(const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
This method performs threshold checks and invokes filters before delegating actual logging to the sub...
std::recursive_mutex mutex
Definition: appenderskeleton.h:77
void setName(const LogString &name1)
Set the name of this Appender.
Definition: appenderskeleton.h:210
spi::FilterPtr tailFilter
The last filter in the filter chain.
Definition: appenderskeleton.h:69
log4cxx::helpers::Pool pool
Definition: appenderskeleton.h:76
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:57
base class for java-like objects.
Definition: object.h:102
Definition: pool.h:33
std::shared_ptr< Filter > FilterPtr
Definition: appender.h:41
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:38
std::shared_ptr< ErrorHandler > ErrorHandlerPtr
Definition: appender.h:44
Definition: messagehandler.h:23
std::basic_string< logchar > LogString
Definition: logstring.h:66
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:28
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:48
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:26
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:141