Apache Log4cxx Version 1.1.0
Loading...
Searching...
No Matches
domconfigurator.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_XML_DOM_CONFIGURATOR_H
19#define _LOG4CXX_XML_DOM_CONFIGURATOR_H
20
21#include <log4cxx/logstring.h>
22#include <map>
23#include <log4cxx/appender.h>
24#include <log4cxx/layout.h>
25#include <log4cxx/logger.h>
29#include <log4cxx/spi/filter.h>
32#include <log4cxx/file.h>
34
35extern "C" {
36 struct apr_xml_doc;
37 struct apr_xml_elem;
38}
39
40namespace log4cxx
41{
42
43namespace xml
44{
45class XMLWatchdog;
46
62class LOG4CXX_EXPORT DOMConfigurator :
63 virtual public spi::Configurator
64{
65 public:
67
68 protected:
69 typedef std::map<LogString, AppenderPtr> AppenderMap;
75 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
76 apr_xml_elem* elem,
77 apr_xml_doc* doc,
78 const LogString& appenderName,
79 AppenderMap& appenders);
80
86 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
87 apr_xml_elem* appenderRef,
88 apr_xml_doc* doc,
89 AppenderMap& appenders);
90
96 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
97 apr_xml_elem* appenderElement,
98 apr_xml_doc* doc,
99 AppenderMap& appenders);
100
106 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
107 apr_xml_elem* element,
108 AppenderPtr& appender,
109 apr_xml_doc* doc,
110 AppenderMap& appenders);
111
117 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
118 apr_xml_elem* element,
119 std::vector<log4cxx::spi::FilterPtr>& filters);
120
126 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
127 apr_xml_elem* loggerElement,
128 apr_xml_doc* doc,
129 AppenderMap& appenders);
130
136 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
137 apr_xml_elem* factoryElement);
138
144 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
145 apr_xml_elem* factoryElement);
146
150 log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
152 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
153 apr_xml_elem* factoryElement);
154
159 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
160 apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
161
167 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
168 apr_xml_elem* catElement,
169 LoggerPtr logger, bool isRoot,
170 apr_xml_doc* doc,
171 AppenderMap& appenders );
172
178 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
179 apr_xml_elem* layout_element);
180
186 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
187 apr_xml_elem* element,
188 LoggerPtr logger, bool isRoot);
189
192 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
193 apr_xml_elem* elem,
195
200 void parse(
202 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
203 apr_xml_elem* element,
204 apr_xml_doc* doc,
205 AppenderMap& appenders);
206
207 public:
209
212 LOG4CXX_CAST_ENTRY(spi::Configurator)
214
215 DOMConfigurator(log4cxx::helpers::Pool& p);
216
220 static spi::ConfigurationStatus configure(const std::string& filename);
221#if LOG4CXX_WCHAR_T_API
222 static spi::ConfigurationStatus configure(const std::wstring& filename);
223#endif
224#if LOG4CXX_UNICHAR_API
225 static spi::ConfigurationStatus configure(const std::basic_string<UniChar>& filename);
226#endif
227#if LOG4CXX_CFSTRING_API
229#endif
236 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename);
237#if LOG4CXX_WCHAR_T_API
238 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename);
239#endif
240#if LOG4CXX_UNICHAR_API
241 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename);
242#endif
243#if LOG4CXX_CFSTRING_API
245#endif
257 static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename,
258 long delay);
259#if LOG4CXX_WCHAR_T_API
260 static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename,
261 long delay);
262#endif
263#if LOG4CXX_UNICHAR_API
264 static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename,
265 long delay);
266#endif
267#if LOG4CXX_CFSTRING_API
269 long delay);
270#endif
271
280 spi::LoggerRepositoryPtr repository) override;
281
282 protected:
284 log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
285 apr_xml_elem*,
286 const std::string& attrName);
287
288 LogString subst(const LogString& value);
289
290 private:
291 // prevent assignment or copy statements
293 DOMConfigurator& operator=(const DOMConfigurator&);
294 static XMLWatchdog* xdog;
295
296 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(DOMConfiguratorPrivate, m_priv)
297};
299} // namespace xml
300} // namespace log4cxx
301
302#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition: file.h:41
General purpose Object property setter.
Definition: propertysetter.h:56
Definition: pool.h:33
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:39
Use this class to initialize the log4cxx environment using a DOM tree.
Definition: domconfigurator.h:64
spi::ConfigurationStatus doConfigure(const File &filename, spi::LoggerRepositoryPtr repository) override
Interpret the XML file pointed by filename and set up log4cxx accordingly.
void parseErrorHandler(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, AppenderPtr &appender, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse an ErrorHandler element.
void parseLevel(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, LoggerPtr logger, bool isRoot)
Used internally to parse a level element.
static spi::ConfigurationStatus configure(const std::basic_string< UniChar > &filename)
static spi::ConfigurationStatus configure(const std::wstring &filename)
void parseLoggerFactory(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
AppenderPtr parseAppender(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse an appender element.
void parseRoot(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *rootElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse the root logger element.
static spi::ConfigurationStatus configure(const CFStringRef &filename)
log4cxx::helpers::ObjectPtr parseTriggeringPolicy(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
AppenderPtr findAppenderByReference(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderRef, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse appenders by IDREF element.
static spi::ConfigurationStatus configureAndWatch(const CFStringRef &configFilename, long delay)
static spi::ConfigurationStatus configureAndWatch(const CFStringRef &configFilename)
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename)
std::map< LogString, AppenderPtr > AppenderMap
Definition: domconfigurator.h:69
LayoutPtr parseLayout(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *layout_element)
Used internally to parse a layout element.
void setParameter(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, log4cxx::config::PropertySetter &propSetter)
void parseFilters(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, std::vector< log4cxx::spi::FilterPtr > &filters)
Used internally to parse a filter element.
static spi::ConfigurationStatus configureAndWatch(const std::string &configFilename)
Like configureAndWatch(const std::string& configFilename, long delay) except that the default delay a...
static spi::ConfigurationStatus configureAndWatch(const std::string &configFilename, long delay)
Read the configuration file configFilename if it exists.
void parseChildrenOfLoggerElement(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *catElement, LoggerPtr logger, bool isRoot, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse the children of a logger element.
LogString subst(const LogString &value)
AppenderPtr findAppenderByName(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, apr_xml_doc *doc, const LogString &appenderName, AppenderMap &appenders)
Used internally to parse appenders by IDREF name.
void parseLogger(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *loggerElement, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to parse a logger element.
log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
Used internally to parse the logger factory element.
static LogString getAttribute(log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *, const std::string &attrName)
static spi::ConfigurationStatus configureAndWatch(const std::wstring &configFilename, long delay)
static spi::ConfigurationStatus configureAndWatch(const std::basic_string< UniChar > &configFilename, long delay)
void parse(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, apr_xml_doc *doc, AppenderMap &appenders)
Used internally to configure the log4cxx framework from an in-memory representation of an XML documen...
static spi::ConfigurationStatus configureAndWatch(const std::wstring &configFilename)
const struct __CFString * CFStringRef
Definition: logstring.h:30
std::shared_ptr< Object > ObjectPtr
Definition: optionconverter.h:41
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: optionconverter.h:33
ConfigurationStatus
Definition: configurator.h:30
LOG4CXX_PTR_DEF(DOMConfigurator)
Definition: configuration.h:25
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:42
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:29
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:27
#define LOG4CXX_CAST_ENTRY(Interface)
Definition: object.h:157
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:151
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:42
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:145