Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
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>
27#include <log4cxx/level.h>
28
29namespace LOG4CXX_NS
30{
31
38class LOG4CXX_EXPORT AppenderSkeleton
39 : public Appender
40{
41 protected:
42 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(AppenderSkeletonPrivate, m_priv)
43 AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv);
44
50 virtual void append( const spi::LoggingEventPtr& event ) = 0;
51
57 void doAppendImpl( const spi::LoggingEventPtr& event );
61 bool isAccepted(const spi::LoggingEventPtr& event) const;
62
63 public:
68 LOG4CXX_CAST_ENTRY(spi::OptionHandler)
70
73 virtual ~AppenderSkeleton();
74
75
76 using spi::OptionHandler::activateOptions;
82 void activateOptions( ) override;
83
92 void setOption(const LogString& option, const LogString& value) override;
93
97 void addFilter(const spi::FilterPtr newFilter) override;
98
99 public:
103 void clearFilters() override;
104
109 const spi::ErrorHandlerPtr getErrorHandler() const;
110
114 spi::FilterPtr getFilter() const override;
115
121 const spi::FilterPtr getFirstFilter() const;
122
126 LayoutPtr getLayout() const override;
127
128
132 LogString getName() const override;
133
138 const LevelPtr getThreshold() const;
139
145 bool isAsSevereAsThreshold(const LevelPtr& level) const;
146
147
154 void doAppend( const spi::LoggingEventPtr& event ) override;
155
159 void setErrorHandler(const spi::ErrorHandlerPtr eh);
160
165 void setLayout(const LayoutPtr layout1) override;
166
170 void setName(const LogString& name1) override;
171
172
181 void setThreshold(const LevelPtr& threshold);
182
183}; // class AppenderSkeleton
184
186} // namespace log4cxx
187
188#endif //_LOG4CXX_APPENDER_SKELETON_H
Implementation base class for all appenders.
Definition appenderskeleton.h:40
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 activateOptions() override
Activate the options that were previously set with calls to option setters.
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.
virtual void append(const spi::LoggingEventPtr &event)=0
Subclasses of AppenderSkeleton must implement this method to perform actual logging.
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 doAppendImpl(const spi::LoggingEventPtr &event)
Compare event level against the appender threshold and check that event is accepted.
bool isAccepted(const spi::LoggingEventPtr &event) const
Does no attached filter deny event or does an attached filter accept event?
void clearFilters() override
Clear the filters chain.
void doAppend(const spi::LoggingEventPtr &event) override
Call AppenderSkeleton::doAppendImpl after acquiring a lock that prevents other threads from concurren...
AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv)
const spi::ErrorHandlerPtr getErrorHandler() const
Return the currently set spi::ErrorHandler for this Appender.
Implement this interface for your own strategies for outputting log statements.
Definition appender.h:51
Definition appender.h:30
std::basic_string< logchar > LogString
Definition logstring.h:51
std::shared_ptr< Level > LevelPtr
Definition optionconverter.h:28
std::shared_ptr< Layout > LayoutPtr
Definition appender.h:42
LOG4CXX_PTR_DEF(Appender)
#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