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>
26#include <log4cxx/level.h>
27
28namespace LOG4CXX_NS
29{
30
37class LOG4CXX_EXPORT AppenderSkeleton
38 : public Appender
39{
40 protected:
41 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(AppenderSkeletonPrivate, m_priv)
42 AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv);
43
49 virtual void append( const spi::LoggingEventPtr& event ) = 0;
50
56 void doAppendImpl( const spi::LoggingEventPtr& event );
60 bool isAccepted(const spi::LoggingEventPtr& event) const;
61
62 public:
67 LOG4CXX_CAST_ENTRY(spi::OptionHandler)
69
70 AppenderSkeleton(const LayoutPtr& layout = {});
72
73
80 void activateOptions( ) override;
81
90 void setOption(const LogString& option, const LogString& value) override;
91
95 void addFilter(const spi::FilterPtr& newFilter) override;
96
97 public:
101 void clearFilters() override;
102
106 void close() override;
107
112
116 spi::FilterPtr getFilter() const override;
117
122
126 LayoutPtr getLayout() const override;
127
131 LogString getName() const override;
132
137 const LevelPtr getThreshold() const;
138
142 bool isAsSevereAsThreshold(const LevelPtr& level) const;
143
150 void doAppend( const spi::LoggingEventPtr& event ) override;
151
156
162 void setLayout(const LayoutPtr& newValue) override;
163
167 void setName(const LogString& newValue) override;
168
169
182 void setThreshold(const LevelPtr& newValue);
183
184}; // class AppenderSkeleton
185
187} // namespace log4cxx
188
189#endif //_LOG4CXX_APPENDER_SKELETON_H
Implementation base class for all appenders.
Definition appenderskeleton.h:39
LogString getName() const override
The name of this Appender.
spi::FilterPtr getFilter() const override
The first spi::Filter in the filter chain for this Appender.
void setLayout(const LayoutPtr &newValue) override
Use newValue as the layout for this appender.
void activateOptions() override
Activate the options that were previously set with calls to option setters.
void addFilter(const spi::FilterPtr &newFilter) override
Add newFilter to end of the spi::Filter chain.
const spi::FilterPtr getFirstFilter() const
The first spi::Filter in the filter chain for this Appender.
LayoutPtr getLayout() const override
The currently set Layout for this appender.
void setOption(const LogString &option, const LogString &value) override
Override this method to set option to value.
const LevelPtr getThreshold() const
This appender's current threshold level.
virtual void append(const spi::LoggingEventPtr &event)=0
Subclasses of AppenderSkeleton must implement this method to perform actual logging.
bool isAsSevereAsThreshold(const LevelPtr &level) const
Is level greater than or equal to this appender's threshold?
void setName(const LogString &newValue) override
Use newValue for the name of this Appender.
void doAppendImpl(const spi::LoggingEventPtr &event)
Call the AppenderSkeleton::append method if the level of event is not lower than this appender's thre...
bool isAccepted(const spi::LoggingEventPtr &event) const
Does no attached filter deny event or does an attached filter accept event?
void close() override
Release any resources allocated within the appender such as file handles, network connections,...
void clearFilters() override
Clear the spi::Filter chain.
void doAppend(const spi::LoggingEventPtr &event) override
Call doAppendImpl after acquiring a lock that prevents other threads from concurrently executing doAp...
void setThreshold(const LevelPtr &newValue)
Use newValue as this appender's threshold level.
AppenderSkeleton(LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv)
void setErrorHandler(const spi::ErrorHandlerPtr &newValue)
Use newValue as the spi::ErrorHandler for this Appender.
const spi::ErrorHandlerPtr getErrorHandler() const
The currently set spi::ErrorHandler for this Appender.
Implement this interface for your own strategies for outputting log statements.
Definition appender.h:51
virtual void activateOptions()=0
Activate the options that were previously set with calls to option setters.
Definition appender.h:30
std::shared_ptr< ErrorHandler > ErrorHandlerPtr
Definition appender.h:38
std::shared_ptr< Filter > FilterPtr
Definition appender.h:35
std::shared_ptr< LoggingEvent > LoggingEventPtr
Definition appender.h:32
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:153
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition object.h:37
#define END_LOG4CXX_CAST_MAP()
Definition object.h:147
#define BEGIN_LOG4CXX_CAST_MAP()
Definition object.h:141