Apache Log4cxx  Version 1.8.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 #include <log4cxx/appender.h>
22 #include <log4cxx/layout.h>
24 #include <log4cxx/spi/filter.h>
25 #include <log4cxx/helpers/object.h>
26 #include <log4cxx/helpers/pool.h>
27 #include <log4cxx/level.h>
28 
29 namespace LOG4CXX_NS
30 {
31 
38 class LOG4CXX_EXPORT AppenderSkeleton
39 #if LOG4CXX_ABI_VERSION <= 15
40  : public virtual Appender
41  , public virtual helpers::Object
42 #else
43  : public Appender
44 #endif
45 {
46  protected:
47  LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(AppenderSkeletonPrivate, m_priv)
48  AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv);
49 
55  virtual void append( LOG4CXX_APPEND_FORMAL_PARAMETERS ) = 0;
56 
62  void doAppendImpl( LOG4CXX_APPEND_FORMAL_PARAMETERS );
66  bool isAccepted(const spi::LoggingEventPtr& event) const;
67 
68  public:
73  LOG4CXX_CAST_ENTRY(spi::OptionHandler)
75 
77  AppenderSkeleton(const LayoutPtr& layout);
78  virtual ~AppenderSkeleton();
79 
80 #if LOG4CXX_ABI_VERSION <= 15
85  [[ deprecated( "The derived appender destructor needs to implement its cleanup" ) ]]
86  void finalize();
87 #endif
88 
89  using spi::OptionHandler::activateOptions;
98 
107  void setOption(const LogString& option, const LogString& value) override;
108 
112  void addFilter(const spi::FilterPtr newFilter) override;
113 
114  public:
118  void clearFilters() override;
119 
125 
129  spi::FilterPtr getFilter() const override;
130 
137 
141  LayoutPtr getLayout() const override;
142 
143 
147  LogString getName() const override;
148 
153  const LevelPtr getThreshold() const;
154 
160  bool isAsSevereAsThreshold(const LevelPtr& level) const;
161 
162 
170 
175 
180  void setLayout(const LayoutPtr layout1) override;
181 
185  void setName(const LogString& name1) override;
186 
187 
196  void setThreshold(const LevelPtr& threshold);
197 
198 }; // class AppenderSkeleton
199 
201 } // namespace log4cxx
202 
203 #endif //_LOG4CXX_APPENDER_SKELETON_H
#define LOG4CXX_APPEND_FORMAL_PARAMETERS
Log in Appender specific way.
Definition: appender.h:92
Implementation base class for all appenders.
Definition: appenderskeleton.h:45
LogString getName() const override
Returns the name of this Appender.
void setErrorHandler(const spi::ErrorHandlerPtr eh)
Set the ErrorHandler for this Appender.
spi::FilterPtr getFilter() const override
Returns the head Filter.
void doAppend(const spi::LoggingEventPtr &event, helpers::Pool &p) override
Call AppenderSkeleton::doAppendImpl after acquiring a lock that prevents other threads from concurren...
const spi::FilterPtr getFirstFilter() const
Return the first filter in the filter chain for this Appender.
LayoutPtr getLayout() const override
Returns the layout of this appender.
void setOption(const LogString &option, const LogString &value) override
Set option to value.
const LevelPtr getThreshold() const
Returns this appenders threshold level.
void setName(const LogString &name1) override
Set the name of this Appender.
void setLayout(const LayoutPtr layout1) override
Set the layout for this appender.
void setThreshold(const LevelPtr &threshold)
Set the threshold level.
void addFilter(const spi::FilterPtr newFilter) override
Add a filter to end of the filter list.
bool isAsSevereAsThreshold(const LevelPtr &level) const
Check whether the message level is below the appender's threshold.
void clearFilters() override
Clear the filters chain.
const spi::ErrorHandlerPtr getErrorHandler() const
Return the currently set spi::ErrorHandler for this Appender.
void finalize()
Finalize this appender by calling the derived class' close method.
void activateOptions(helpers::Pool &p) override
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:55
base class for java-like objects.
Definition: object.h:102
std::shared_ptr< ErrorHandler > ErrorHandlerPtr
Definition: appender.h:37
std::shared_ptr< Filter > FilterPtr
Definition: appender.h:34
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition: appender.h:31
LOG4CXX_PTR_DEF(AppenderSkeleton)
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Level > LevelPtr
Definition: optionconverter.h:27
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:41
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:154
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:148
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:142
#define LOG4CXX_ACTIVATE_OPTIONS_FORMAL_PARAMETERS
Activate the options that were previously set with calls to option setters.
Definition: optionhandler.h:53