[2] | 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 |
|
---|
| 21 | #if defined(_MSC_VER)
|
---|
| 22 | #pragma warning ( push )
|
---|
| 23 | #pragma warning ( disable: 4231 4251 4275 4786 )
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #include <log4cxx/spi/optionhandler.h>
|
---|
| 28 | #include <log4cxx/helpers/objectptr.h>
|
---|
| 29 | #include <log4cxx/helpers/object.h>
|
---|
| 30 | #include <vector>
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | namespace log4cxx
|
---|
| 34 | {
|
---|
| 35 | // Forward declarations
|
---|
| 36 | namespace spi
|
---|
| 37 | {
|
---|
| 38 | class LoggingEvent;
|
---|
| 39 | typedef helpers::ObjectPtrT<LoggingEvent> LoggingEventPtr;
|
---|
| 40 |
|
---|
| 41 | class Filter;
|
---|
| 42 | typedef helpers::ObjectPtrT<Filter> FilterPtr;
|
---|
| 43 |
|
---|
| 44 | class ErrorHandler;
|
---|
| 45 | typedef log4cxx::helpers::ObjectPtrT<ErrorHandler> ErrorHandlerPtr;
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | class Layout;
|
---|
| 49 | typedef log4cxx::helpers::ObjectPtrT<Layout> LayoutPtr;
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | /**
|
---|
| 53 | Implement this interface for your own strategies for outputting log
|
---|
| 54 | statements.
|
---|
| 55 | */
|
---|
| 56 | class LOG4CXX_EXPORT Appender :
|
---|
| 57 | public virtual spi::OptionHandler
|
---|
| 58 | {
|
---|
| 59 | public:
|
---|
| 60 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(Appender)
|
---|
| 61 |
|
---|
| 62 | virtual ~Appender() {}
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | Add a filter to the end of the filter list.
|
---|
| 66 | */
|
---|
| 67 | virtual void addFilter(const spi::FilterPtr& newFilter) = 0;
|
---|
| 68 |
|
---|
| 69 | /**
|
---|
| 70 | Returns the head Filter. The Filters are organized in a linked list
|
---|
| 71 | and so all Filters on this Appender are available through the result.
|
---|
| 72 |
|
---|
| 73 | @return the head Filter or null, if no Filters are present
|
---|
| 74 | */
|
---|
| 75 | virtual spi::FilterPtr getFilter() const = 0;
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | Clear the list of filters by removing all the filters in it.
|
---|
| 79 | */
|
---|
| 80 | virtual void clearFilters() = 0;
|
---|
| 81 |
|
---|
| 82 | /**
|
---|
| 83 | Release any resources allocated within the appender such as file
|
---|
| 84 | handles, network connections, etc.
|
---|
| 85 | <p>It is a programming error to append to a closed appender.
|
---|
| 86 | */
|
---|
| 87 | virtual void close() = 0;
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | Log in <code>Appender</code> specific way. When appropriate,
|
---|
| 91 | Loggers will call the <code>doAppend</code> method of appender
|
---|
| 92 | implementations in order to log.
|
---|
| 93 | */
|
---|
| 94 | virtual void doAppend(const spi::LoggingEventPtr& event,
|
---|
| 95 | log4cxx::helpers::Pool& pool) = 0;
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | /**
|
---|
| 99 | Get the name of this appender. The name uniquely identifies the
|
---|
| 100 | appender.
|
---|
| 101 | */
|
---|
| 102 | virtual LogString getName() const = 0;
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | /**
|
---|
| 106 | Set the Layout for this appender.
|
---|
| 107 | */
|
---|
| 108 | virtual void setLayout(const LayoutPtr& layout) = 0;
|
---|
| 109 |
|
---|
| 110 | /**
|
---|
| 111 | Returns this appenders layout.
|
---|
| 112 | */
|
---|
| 113 | virtual LayoutPtr getLayout() const = 0;
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | /**
|
---|
| 117 | Set the name of this appender. The name is used by other
|
---|
| 118 | components to identify this appender.
|
---|
| 119 | */
|
---|
| 120 | virtual void setName(const LogString& name) = 0;
|
---|
| 121 |
|
---|
| 122 | /**
|
---|
| 123 | Configurators call this method to determine if the appender
|
---|
| 124 | requires a layout. If this method returns <code>true</code>,
|
---|
| 125 | meaning that layout is required, then the configurator will
|
---|
| 126 | configure an layout using the configuration information at its
|
---|
| 127 | disposal. If this method returns <code>false</code>, meaning that
|
---|
| 128 | a layout is not required, then layout configuration will be
|
---|
| 129 | skipped even if there is available layout configuration
|
---|
| 130 | information at the disposal of the configurator..
|
---|
| 131 |
|
---|
| 132 | <p>In the rather exceptional case, where the appender
|
---|
| 133 | implementation admits a layout but can also work without it, then
|
---|
| 134 | the appender should return <code>true</code>.
|
---|
| 135 | */
|
---|
| 136 | virtual bool requiresLayout() const = 0;
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 | LOG4CXX_PTR_DEF(Appender);
|
---|
| 140 | LOG4CXX_LIST_DEF(AppenderList, AppenderPtr);
|
---|
| 141 |
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | #if defined(_MSC_VER)
|
---|
| 145 | #pragma warning ( pop )
|
---|
| 146 | #endif
|
---|
| 147 |
|
---|
| 148 | #endif //_LOG4CXX_APPENDER_H
|
---|