Apache Log4cxx  Version 1.1.0
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 
35 extern "C" {
36  struct apr_xml_doc;
37  struct apr_xml_elem;
38 }
39 
40 namespace log4cxx
41 {
42 
43 namespace xml
44 {
45 class XMLWatchdog;
46 
62 class LOG4CXX_EXPORT DOMConfigurator :
63  virtual public spi::Configurator,
64  virtual public helpers::Object
65 {
66  public:
68 
69  protected:
70  typedef std::map<LogString, AppenderPtr> AppenderMap;
76  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
77  apr_xml_elem* elem,
78  apr_xml_doc* doc,
79  const LogString& appenderName,
80  AppenderMap& appenders);
81 
87  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
88  apr_xml_elem* appenderRef,
89  apr_xml_doc* doc,
90  AppenderMap& appenders);
91 
97  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
98  apr_xml_elem* appenderElement,
99  apr_xml_doc* doc,
100  AppenderMap& appenders);
101 
107  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
108  apr_xml_elem* element,
109  AppenderPtr& appender,
110  apr_xml_doc* doc,
111  AppenderMap& appenders);
112 
118  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
119  apr_xml_elem* element,
120  std::vector<log4cxx::spi::FilterPtr>& filters);
121 
127  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
128  apr_xml_elem* loggerElement,
129  apr_xml_doc* doc,
130  AppenderMap& appenders);
131 
137  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
138  apr_xml_elem* factoryElement);
139 
145  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
146  apr_xml_elem* factoryElement);
147 
151  log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
153  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
154  apr_xml_elem* factoryElement);
155 
160  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
161  apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
162 
168  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
169  apr_xml_elem* catElement,
170  LoggerPtr logger, bool isRoot,
171  apr_xml_doc* doc,
172  AppenderMap& appenders );
173 
179  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
180  apr_xml_elem* layout_element);
181 
187  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
188  apr_xml_elem* element,
189  LoggerPtr logger, bool isRoot);
190 
193  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
194  apr_xml_elem* elem,
195  log4cxx::config::PropertySetter& propSetter);
196 
201  void parse(
203  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
204  apr_xml_elem* element,
205  apr_xml_doc* doc,
206  AppenderMap& appenders);
207 
208  public:
210 
213  LOG4CXX_CAST_ENTRY(spi::Configurator)
215 
216  DOMConfigurator(log4cxx::helpers::Pool& p);
217 
221  static spi::ConfigurationStatus configure(const std::string& filename);
222 #if LOG4CXX_WCHAR_T_API
223  static spi::ConfigurationStatus configure(const std::wstring& filename);
224 #endif
225 #if LOG4CXX_UNICHAR_API
226  static spi::ConfigurationStatus configure(const std::basic_string<UniChar>& filename);
227 #endif
228 #if LOG4CXX_CFSTRING_API
230 #endif
237  static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename);
238 #if LOG4CXX_WCHAR_T_API
239  static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename);
240 #endif
241 #if LOG4CXX_UNICHAR_API
242  static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename);
243 #endif
244 #if LOG4CXX_CFSTRING_API
246 #endif
258  static spi::ConfigurationStatus configureAndWatch(const std::string& configFilename,
259  long delay);
260 #if LOG4CXX_WCHAR_T_API
261  static spi::ConfigurationStatus configureAndWatch(const std::wstring& configFilename,
262  long delay);
263 #endif
264 #if LOG4CXX_UNICHAR_API
265  static spi::ConfigurationStatus configureAndWatch(const std::basic_string<UniChar>& configFilename,
266  long delay);
267 #endif
268 #if LOG4CXX_CFSTRING_API
270  long delay);
271 #endif
272 
281  spi::LoggerRepositoryPtr repository) override;
282 
283  protected:
285  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
286  apr_xml_elem*,
287  const std::string& attrName);
288 
289  LogString subst(const LogString& value);
290 
291  private:
292  // prevent assignment or copy statements
294  DOMConfigurator& operator=(const DOMConfigurator&);
295  static XMLWatchdog* xdog;
296 
297  LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(DOMConfiguratorPrivate, m_priv)
298 };
300 } // namespace xml
301 } // namespace log4cxx
302 
303 #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
base class for java-like objects.
Definition: object.h:105
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:65
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:70
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:40
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: optionconverter.h:32
ConfigurationStatus
Definition: configurator.h:30
LOG4CXX_PTR_DEF(DOMConfigurator)
Definition: appender.h:27
std::basic_string< logchar > LogString
Definition: logstring.h:60
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:41
std::shared_ptr< Appender > AppenderPtr
Definition: basicconfigurator.h:28
std::shared_ptr< Logger > LoggerPtr
Definition: defaultloggerfactory.h:26
#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