Apache Log4cxx  Version 1.8.0
appender.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_H
19 #define _LOG4CXX_APPENDER_H
20 
22 #include <log4cxx/helpers/object.h>
23 #include <vector>
24 
25 
26 namespace LOG4CXX_NS
27 {
28 // Forward declarations
29 namespace spi
30 {
31 class LoggingEvent;
32 typedef std::shared_ptr<LoggingEvent> LoggingEventPtr;
33 
34 class Filter;
35 typedef std::shared_ptr<Filter> FilterPtr;
36 
37 class ErrorHandler;
38 typedef std::shared_ptr<ErrorHandler> ErrorHandlerPtr;
39 }
40 
41 class Layout;
42 typedef std::shared_ptr<Layout> LayoutPtr;
43 
44 
49 class LOG4CXX_EXPORT Appender
50 #if LOG4CXX_ABI_VERSION <= 15
51  : public virtual spi::OptionHandler
52 #else
53  : public spi::OptionHandler
54 #endif
55 {
56  public:
58 
59  virtual ~Appender() {}
60 
64  virtual void addFilter(const spi::FilterPtr newFilter) = 0;
65 
72  virtual spi::FilterPtr getFilter() const = 0;
73 
77  virtual void clearFilters() = 0;
78 
84  virtual void close() = 0;
85 
91 #if LOG4CXX_ABI_VERSION <= 15
92 #define LOG4CXX_APPEND_FORMAL_PARAMETERS const spi::LoggingEventPtr& event, helpers::Pool& p
93 #define LOG4CXX_APPEND_PARAMETERS event, p
94  void doAppend(const spi::LoggingEventPtr& event);
99  virtual void doAppend(const spi::LoggingEventPtr& event,
100  LOG4CXX_NS::helpers::Pool& pool) = 0;
101 #else
102 #define LOG4CXX_APPEND_FORMAL_PARAMETERS const spi::LoggingEventPtr& event
103 #define LOG4CXX_APPEND_PARAMETERS event
104  virtual void doAppend(const spi::LoggingEventPtr& event) = 0;
108  [[deprecated("Use doAppend() without a Pool parameter instead")]]
109  void doAppend(const spi::LoggingEventPtr& event, helpers::Pool& pool);
110 #endif
111 
116  virtual LogString getName() const = 0;
117 
118 
122  virtual void setLayout(const LayoutPtr layout) = 0;
123 
127  virtual LayoutPtr getLayout() const = 0;
128 
129 
134  virtual void setName(const LogString& name) = 0;
135 
150  virtual bool requiresLayout() const = 0;
151 };
152 
155 
156 }
157 
158 #endif //_LOG4CXX_APPENDER_H
Implement this interface for your own strategies for outputting log statements.
Definition: appender.h:55
virtual void doAppend(const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)=0
virtual LogString getName() const =0
Get the name of this appender.
virtual void addFilter(const spi::FilterPtr newFilter)=0
Add a filter to the end of the filter list.
virtual spi::FilterPtr getFilter() const =0
Returns the head Filter.
virtual bool requiresLayout() const =0
Configurators call this method to determine if the appender requires a layout.
virtual void close()=0
Release any resources allocated within the appender such as file handles, network connections,...
virtual void clearFilters()=0
Clear the list of filters by removing all the filters in it.
virtual LayoutPtr getLayout() const =0
Returns this appenders layout.
virtual void setLayout(const LayoutPtr layout)=0
Set the Layout for this appender.
virtual void setName(const LogString &name)=0
Set the name of this appender.
void doAppend(const spi::LoggingEventPtr &event)
Extend this abstract class to create your own log layout format.
Definition: layout.h:38
Definition: pool.h:33
Appenders may delegate their error handling to ErrorHandlers.
Definition: errorhandler.h:64
Users should extend this class to implement customized logging event filtering.
Definition: filter.h:73
The data recorded for each logging request.
Definition: loggingevent.h:47
A string based interface to configure package components.
Definition: optionhandler.h:35
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_LIST_DEF(AppenderList, AppenderPtr)
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:41
LOG4CXX_PTR_DEF(Appender)
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:28
#define DECLARE_ABSTRACT_LOG4CXX_OBJECT(object)
Definition: object.h:37