Apache log4cxx  Version 0.12.1
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 #if defined(_MSC_VER)
22  #pragma warning (push)
23  #pragma warning ( disable: 4231 4251 4275 4786 )
24 #endif
25 
26 
27 
28 #include <log4cxx/logstring.h>
29 #include <map>
30 #include <log4cxx/appender.h>
31 #include <log4cxx/layout.h>
32 #include <log4cxx/logger.h>
36 #include <log4cxx/spi/filter.h>
39 #include <log4cxx/file.h>
41 
42 extern "C" {
43  struct apr_xml_doc;
44  struct apr_xml_elem;
45 }
46 
47 namespace log4cxx
48 {
49 
50 namespace xml
51 {
52 class XMLWatchdog;
53 
69 class LOG4CXX_EXPORT DOMConfigurator :
70  virtual public spi::Configurator,
71  virtual public helpers::Object
72 {
73  protected:
74  typedef std::map<LogString, AppenderPtr> AppenderMap;
80  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
81  apr_xml_elem* elem,
82  apr_xml_doc* doc,
83  const LogString& appenderName,
84  AppenderMap& appenders);
85 
91  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
92  apr_xml_elem* appenderRef,
93  apr_xml_doc* doc,
94  AppenderMap& appenders);
95 
101  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
102  apr_xml_elem* appenderElement,
103  apr_xml_doc* doc,
104  AppenderMap& appenders);
105 
111  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
112  apr_xml_elem* element,
113  AppenderPtr& appender,
114  apr_xml_doc* doc,
115  AppenderMap& appenders);
116 
122  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
123  apr_xml_elem* element,
124  std::vector<log4cxx::spi::FilterPtr>& filters);
125 
131  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
132  apr_xml_elem* loggerElement,
133  apr_xml_doc* doc,
134  AppenderMap& appenders);
135 
141  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
142  apr_xml_elem* factoryElement);
143 
149  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
150  apr_xml_elem* factoryElement);
151 
155  log4cxx::rolling::RollingPolicyPtr parseRollingPolicy(
157  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
158  apr_xml_elem* factoryElement);
159 
164  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
165  apr_xml_elem* rootElement, apr_xml_doc* doc, AppenderMap& appenders);
166 
172  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
173  apr_xml_elem* catElement,
174  LoggerPtr logger, bool isRoot,
175  apr_xml_doc* doc,
176  AppenderMap& appenders );
177 
183  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
184  apr_xml_elem* layout_element);
185 
191  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
192  apr_xml_elem* element,
193  LoggerPtr logger, bool isRoot);
194 
197  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
198  apr_xml_elem* elem,
199  log4cxx::config::PropertySetter& propSetter);
200 
205  void parse(
207  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
208  apr_xml_elem* element,
209  apr_xml_doc* doc,
210  AppenderMap& appenders);
211 
212  public:
214 
217  LOG4CXX_CAST_ENTRY(spi::Configurator)
219 
220  DOMConfigurator(log4cxx::helpers::Pool& p);
221 
225  static void configure(const std::string& filename);
226 #if LOG4CXX_WCHAR_T_API
227  static void configure(const std::wstring& filename);
228 #endif
229 #if LOG4CXX_UNICHAR_API
230  static void configure(const std::basic_string<UniChar>& filename);
231 #endif
232 #if LOG4CXX_CFSTRING_API
233  static void configure(const CFStringRef& filename);
234 #endif
241  static void configureAndWatch(const std::string& configFilename);
242 #if LOG4CXX_WCHAR_T_API
243  static void configureAndWatch(const std::wstring& configFilename);
244 #endif
245 #if LOG4CXX_UNICHAR_API
246  static void configureAndWatch(const std::basic_string<UniChar>& configFilename);
247 #endif
248 #if LOG4CXX_CFSTRING_API
249  static void configureAndWatch(const CFStringRef& configFilename);
250 #endif
262  static void configureAndWatch(const std::string& configFilename,
263  long delay);
264 #if LOG4CXX_WCHAR_T_API
265  static void configureAndWatch(const std::wstring& configFilename,
266  long delay);
267 #endif
268 #if LOG4CXX_UNICHAR_API
269  static void configureAndWatch(const std::basic_string<UniChar>& configFilename,
270  long delay);
271 #endif
272 #if LOG4CXX_CFSTRING_API
273  static void configureAndWatch(const CFStringRef& configFilename,
274  long delay);
275 #endif
276 
284  void doConfigure(const File& filename,
285  spi::LoggerRepositoryPtr repository);
286 
287  protected:
289  log4cxx::helpers::CharsetDecoderPtr& utf8Decoder,
290  apr_xml_elem*,
291  const std::string& attrName);
292 
293  LogString subst(const LogString& value);
294 
295  protected:
299 
300  private:
301  // prevent assignment or copy statements
303  DOMConfigurator& operator=(const DOMConfigurator&);
304  static XMLWatchdog* xdog;
305 };
307 } // namespace xml
308 } // namespace log4cxx
309 
310 #if defined(_MSC_VER)
311  #pragma warning (pop)
312 #endif
313 
314 #endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
An abstract representation of file and directory path names.
Definition: file.h:46
General purpose Object property setter.
Definition: propertysetter.h:54
base class for java-like objects.
Definition: object.h:102
Definition: pool.h:33
Definition: properties.h:39
Implemented by classes capable of configuring log4j using a URL.
Definition: configurator.h:33
Use this class to initialize the log4cxx environment using a DOM tree.
Definition: domconfigurator.h:72
static void configureAndWatch(const CFStringRef &configFilename, long delay)
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.
helpers::Properties props
Definition: domconfigurator.h:296
static void 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.
static void configureAndWatch(const std::wstring &configFilename)
static void configureAndWatch(const std::string &configFilename, long delay)
Read the configuration file configFilename if it exists.
static void configureAndWatch(const std::string &configFilename)
Like configureAndWatch(const std::string& configFilename, long delay) except that the default delay a...
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.
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 void configureAndWatch(const std::wstring &configFilename, long delay)
std::map< LogString, AppenderPtr > AppenderMap
Definition: domconfigurator.h:74
void doConfigure(const File &filename, spi::LoggerRepositoryPtr repository)
Interpret the XML file pointed by filename and set up log4cxx accordingly.
LayoutPtr parseLayout(log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *layout_element)
Used internally to parse a layout element.
static void configureAndWatch(const CFStringRef &configFilename)
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.
spi::LoggerRepositoryPtr repository
Definition: domconfigurator.h:297
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)
static void configure(const CFStringRef &filename)
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.
static void configure(const std::basic_string< UniChar > &filename)
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.
static void configureAndWatch(const std::basic_string< UniChar > &configFilename)
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)
spi::LoggerFactoryPtr loggerFactory
Definition: domconfigurator.h:298
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 void configureAndWatch(const std::basic_string< UniChar > &configFilename, long delay)
const struct __CFString * CFStringRef
Definition: logstring.h:36
std::shared_ptr< Object > ObjectPtr
Definition: propertysetter.h:28
std::shared_ptr< LoggerFactory > LoggerFactoryPtr
Definition: logmanager.h:38
std::shared_ptr< LoggerRepository > LoggerRepositoryPtr
Definition: defaultconfigurator.h:27
LOG4CXX_PTR_DEF(DOMConfigurator)
Definition: appender.h:33
std::basic_string< logchar > LogString
Definition: logstring.h:66
std::shared_ptr< Layout > LayoutPtr
Definition: appender.h:47
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:148
#define END_LOG4CXX_CAST_MAP()
Definition: object.h:142
#define DECLARE_LOG4CXX_OBJECT(object)
Definition: object.h:39
#define BEGIN_LOG4CXX_CAST_MAP()
Definition: object.h:136