/src/logging-log4cxx/src/main/cpp/domconfigurator.cpp
Line | Count | Source |
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 | | #include <log4cxx/logstring.h> |
18 | | #include <log4cxx/xml/domconfigurator.h> |
19 | | #include <log4cxx/appender.h> |
20 | | #include <log4cxx/asyncappender.h> |
21 | | #include <log4cxx/layout.h> |
22 | | #include <log4cxx/logger.h> |
23 | | #include <log4cxx/logmanager.h> |
24 | | #include <log4cxx/level.h> |
25 | | #include <log4cxx/spi/filter.h> |
26 | | #include <log4cxx/helpers/loglog.h> |
27 | | #include <log4cxx/helpers/stringhelper.h> |
28 | | #include <log4cxx/helpers/loader.h> |
29 | | #include <log4cxx/helpers/optionconverter.h> |
30 | | #include <log4cxx/config/propertysetter.h> |
31 | | #include <log4cxx/spi/errorhandler.h> |
32 | | #include <log4cxx/spi/loggerfactory.h> |
33 | | #if LOG4CXX_ABI_VERSION <= 15 |
34 | | #include <log4cxx/defaultloggerfactory.h> |
35 | | #else |
36 | | #include <log4cxx/spi/loggerfactory.h> |
37 | | #endif |
38 | | #include <log4cxx/helpers/filewatchdog.h> |
39 | | #include <log4cxx/spi/loggerrepository.h> |
40 | | #include <log4cxx/spi/loggingevent.h> |
41 | | #include <log4cxx/helpers/pool.h> |
42 | | #include <sstream> |
43 | | #include <log4cxx/helpers/transcoder.h> |
44 | | #include <log4cxx/rolling/rollingfileappender.h> |
45 | | #include <log4cxx/rolling/filterbasedtriggeringpolicy.h> |
46 | | #include <apr_xml.h> |
47 | | #include <log4cxx/helpers/bytebuffer.h> |
48 | | #include <log4cxx/helpers/charsetdecoder.h> |
49 | | #include <log4cxx/net/smtpappender.h> |
50 | | #include <log4cxx/helpers/messagebuffer.h> |
51 | | #include <log4cxx/helpers/threadutility.h> |
52 | | #include <log4cxx/helpers/singletonholder.h> |
53 | | |
54 | | #define LOG4CXX 1 |
55 | | #include <log4cxx/helpers/aprinitializer.h> |
56 | | |
57 | | using namespace LOG4CXX_NS; |
58 | | using namespace LOG4CXX_NS::xml; |
59 | | using namespace LOG4CXX_NS::helpers; |
60 | | using namespace LOG4CXX_NS::spi; |
61 | | using namespace LOG4CXX_NS::config; |
62 | | using namespace LOG4CXX_NS::rolling; |
63 | | |
64 | 1.32k | #define MAX_ATTRIBUTE_NAME_LEN 2000 |
65 | | |
66 | | struct DOMConfigurator::DOMConfiguratorPrivate |
67 | | { |
68 | | helpers::Properties props = Configurator::properties(); |
69 | | spi::LoggerRepositoryPtr repository; |
70 | | spi::LoggerFactoryPtr loggerFactory; |
71 | | bool appenderAdded{ false }; |
72 | | }; |
73 | | |
74 | | namespace LOG4CXX_NS |
75 | | { |
76 | | namespace xml |
77 | | { |
78 | | class XMLWatchdog : public FileWatchdog |
79 | | { |
80 | | public: |
81 | 0 | XMLWatchdog(const File& filename) : FileWatchdog(filename) |
82 | 0 | { |
83 | 0 | } |
84 | | |
85 | | /** |
86 | | Call DOMConfigurator#doConfigure with the |
87 | | <code>filename</code> to reconfigure log4cxx. |
88 | | */ |
89 | | void doOnChange() |
90 | 0 | { |
91 | 0 | DOMConfigurator().doConfigure(file(), |
92 | 0 | LogManager::getLoggerRepository()); |
93 | 0 | } |
94 | | |
95 | | static void startWatching(const File& filename, long delay) |
96 | 0 | { |
97 | 0 | using WatchdogHolder = SingletonHolder<XMLWatchdog>; |
98 | 0 | auto pHolder = APRInitializer::getOrAddUnique<WatchdogHolder> |
99 | 0 | ( [&filename]() -> ObjectPtr |
100 | 0 | { return std::make_shared<WatchdogHolder>(filename); } |
101 | 0 | ); |
102 | 0 | auto& xdog = pHolder->value(); |
103 | 0 | xdog.setFile(filename); |
104 | 0 | xdog.setDelay(0 < delay ? delay : FileWatchdog::DEFAULT_DELAY); |
105 | 0 | xdog.start(); |
106 | 0 | } |
107 | | }; |
108 | | } |
109 | | } |
110 | | |
111 | | IMPLEMENT_LOG4CXX_OBJECT(DOMConfigurator) |
112 | | |
113 | 1.16k | #define CONFIGURATION_TAG "log4j:configuration" |
114 | 1.00k | #define OLD_CONFIGURATION_TAG "configuration" |
115 | 0 | #define APPENDER_TAG "appender" |
116 | 0 | #define APPENDER_REF_TAG "appender-ref" |
117 | 0 | #define PARAM_TAG "param" |
118 | 0 | #define LAYOUT_TAG "layout" |
119 | 0 | #define ROLLING_POLICY_TAG "rollingPolicy" |
120 | 0 | #define TRIGGERING_POLICY_TAG "triggeringPolicy" |
121 | 0 | #define CATEGORY "category" |
122 | 0 | #define LOGGER "logger" |
123 | 0 | #define LOGGER_REF "logger-ref" |
124 | 0 | #define CATEGORY_FACTORY_TAG "categoryFactory" |
125 | 0 | #define NAME_ATTR "name" |
126 | 0 | #define CLASS_ATTR "class" |
127 | 0 | #define VALUE_ATTR "value" |
128 | 0 | #define ROOT_TAG "root" |
129 | 0 | #define ROOT_REF "root-ref" |
130 | 0 | #define LEVEL_TAG "level" |
131 | 0 | #define PRIORITY_TAG "priority" |
132 | 0 | #define FILTER_TAG "filter" |
133 | 0 | #define ERROR_HANDLER_TAG "errorHandler" |
134 | 0 | #define REF_ATTR "ref" |
135 | 0 | #define ADDITIVITY_ATTR "additivity" |
136 | 0 | #define ASYNCHRONOUS_ATTR "asynchronous" |
137 | 842 | #define THRESHOLD_ATTR "threshold" |
138 | | #define STRINGSTREAM_ATTR "stringstream" |
139 | | #define CONFIG_DEBUG_ATTR "configDebug" |
140 | 842 | #define INTERNAL_DEBUG_ATTR "debug" |
141 | 842 | #define INTERNAL_COLOR_ATTR "color" |
142 | 842 | #define THREAD_CONFIG_ATTR "threadConfiguration" |
143 | | |
144 | | DOMConfigurator::DOMConfigurator() |
145 | 4.38k | : m_priv(std::make_unique<DOMConfiguratorPrivate>()) |
146 | 4.38k | { |
147 | 4.38k | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::DOMConfigurator() log4cxx::xml::DOMConfigurator::DOMConfigurator() Line | Count | Source | 145 | 4.38k | : m_priv(std::make_unique<DOMConfiguratorPrivate>()) | 146 | 4.38k | { | 147 | 4.38k | } |
|
148 | | |
149 | 4.38k | DOMConfigurator::~DOMConfigurator() {} |
150 | | |
151 | | /** |
152 | | Used internally to parse appenders by IDREF name. |
153 | | */ |
154 | | AppenderPtr DOMConfigurator::findAppenderByName(LOG4CXX_NS::helpers::Pool& p, |
155 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
156 | | apr_xml_elem* element, |
157 | | apr_xml_doc* doc, |
158 | | const LogString& appenderName, |
159 | | AppenderMap& appenders) |
160 | 0 | { |
161 | 0 | AppenderPtr appender; |
162 | 0 | std::string tagName(element->name); |
163 | |
|
164 | 0 | if (tagName == APPENDER_TAG) |
165 | 0 | { |
166 | 0 | if (appenderName == getAttribute(utf8Decoder, element, NAME_ATTR)) |
167 | 0 | { |
168 | 0 | appender = parseAppender(p, utf8Decoder, element, doc, appenders); |
169 | 0 | } |
170 | 0 | } |
171 | |
|
172 | 0 | if (element->first_child && !appender) |
173 | 0 | { |
174 | 0 | appender = findAppenderByName(p, utf8Decoder, element->first_child, doc, appenderName, appenders); |
175 | 0 | } |
176 | |
|
177 | 0 | if (element->next && !appender) |
178 | 0 | { |
179 | 0 | appender = findAppenderByName(p, utf8Decoder, element->next, doc, appenderName, appenders); |
180 | 0 | } |
181 | |
|
182 | 0 | return appender; |
183 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::findAppenderByName(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::findAppenderByName(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
184 | | |
185 | | /** |
186 | | Used internally to parse appenders by IDREF element. |
187 | | */ |
188 | | AppenderPtr DOMConfigurator::findAppenderByReference( |
189 | | LOG4CXX_NS::helpers::Pool& p, |
190 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
191 | | apr_xml_elem* appenderRef, |
192 | | apr_xml_doc* doc, |
193 | | AppenderMap& appenders) |
194 | 0 | { |
195 | 0 | AppenderPtr appender; |
196 | 0 | LogString appenderName(subst(getAttribute(utf8Decoder, appenderRef, REF_ATTR))); |
197 | 0 | if (appenderName.empty()) |
198 | 0 | { |
199 | 0 | LogString msg(LOG4CXX_STR("[")); |
200 | 0 | utf8Decoder->decode(appenderRef->name, MAX_ATTRIBUTE_NAME_LEN, msg); |
201 | 0 | msg += LOG4CXX_STR("] attribute ["); |
202 | 0 | utf8Decoder->decode(REF_ATTR, MAX_ATTRIBUTE_NAME_LEN, msg); |
203 | 0 | msg += LOG4CXX_STR("] not found"); |
204 | 0 | LogLog::warn(msg); |
205 | 0 | return appender; |
206 | 0 | } |
207 | 0 | AppenderMap::const_iterator match = appenders.find(appenderName); |
208 | |
|
209 | 0 | if (match != appenders.end()) |
210 | 0 | { |
211 | 0 | appender = match->second; |
212 | 0 | } |
213 | 0 | else if (doc) |
214 | 0 | { |
215 | 0 | appender = findAppenderByName(p, utf8Decoder, doc->root, doc, appenderName, appenders); |
216 | |
|
217 | 0 | if (appender) |
218 | 0 | { |
219 | 0 | appenders.insert(AppenderMap::value_type(appenderName, appender)); |
220 | 0 | } |
221 | 0 | } |
222 | |
|
223 | 0 | if (!appender) |
224 | 0 | { |
225 | 0 | LogLog::error(LOG4CXX_STR("No ") + Appender::getStaticClass().getName() |
226 | 0 | + LOG4CXX_STR(" named [") + appenderName + LOG4CXX_STR("] could be found.")); |
227 | 0 | } |
228 | |
|
229 | 0 | return appender; |
230 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::findAppenderByReference(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::findAppenderByReference(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
231 | | |
232 | | /** |
233 | | Used internally to parse an appender element. |
234 | | */ |
235 | | AppenderPtr DOMConfigurator::parseAppender(Pool& p, |
236 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
237 | | apr_xml_elem* appenderElement, |
238 | | apr_xml_doc* doc, |
239 | | AppenderMap& appenders) |
240 | 0 | { |
241 | |
|
242 | 0 | LogString className(subst(getAttribute(utf8Decoder, appenderElement, CLASS_ATTR))); |
243 | 0 | if (LogLog::isDebugEnabled()) |
244 | 0 | { |
245 | 0 | LogLog::debug(LOG4CXX_STR("Desired ") + Appender::getStaticClass().getName() |
246 | 0 | + LOG4CXX_STR(" sub-class: [") + className + LOG4CXX_STR("]")); |
247 | 0 | } |
248 | |
|
249 | 0 | try |
250 | 0 | { |
251 | 0 | ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance()); |
252 | 0 | AppenderPtr appender = LOG4CXX_NS::cast<Appender>(instance); |
253 | 0 | if(!appender){ |
254 | 0 | LogLog::error(LOG4CXX_STR("Could not cast [") + className + LOG4CXX_STR("] to ") + Appender::getStaticClass().getName()); |
255 | 0 | return AppenderPtr(); |
256 | 0 | } |
257 | 0 | PropertySetter propSetter(appender); |
258 | |
|
259 | 0 | appender->setName(subst(getAttribute(utf8Decoder, appenderElement, NAME_ATTR))); |
260 | |
|
261 | 0 | for (apr_xml_elem* currentElement = appenderElement->first_child; |
262 | 0 | currentElement; |
263 | 0 | currentElement = currentElement->next) |
264 | 0 | { |
265 | |
|
266 | 0 | std::string tagName(currentElement->name); |
267 | | |
268 | | // Parse appender parameters |
269 | 0 | if (tagName == PARAM_TAG) |
270 | 0 | { |
271 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
272 | 0 | } |
273 | | // Set appender layout |
274 | 0 | else if (tagName == LAYOUT_TAG) |
275 | 0 | { |
276 | 0 | appender->setLayout(parseLayout(p, utf8Decoder, currentElement)); |
277 | 0 | } |
278 | | // Add filters |
279 | 0 | else if (tagName == FILTER_TAG) |
280 | 0 | { |
281 | 0 | std::vector<LOG4CXX_NS::spi::FilterPtr> filters; |
282 | 0 | parseFilters(p, utf8Decoder, currentElement, filters); |
283 | |
|
284 | 0 | for (auto& item : filters) |
285 | 0 | { |
286 | 0 | appender->addFilter(item); |
287 | 0 | } |
288 | 0 | } |
289 | 0 | else if (tagName == ERROR_HANDLER_TAG) |
290 | 0 | { |
291 | 0 | parseErrorHandler(p, utf8Decoder, currentElement, appender, doc, appenders); |
292 | 0 | } |
293 | 0 | else if (tagName == ROLLING_POLICY_TAG) |
294 | 0 | { |
295 | 0 | RollingPolicyPtr rollPolicy(parseRollingPolicy(p, utf8Decoder, currentElement)); |
296 | 0 | RollingFileAppenderPtr rfa = LOG4CXX_NS::cast<RollingFileAppender>(appender); |
297 | |
|
298 | 0 | if (rfa != NULL) |
299 | 0 | { |
300 | 0 | rfa->setRollingPolicy(rollPolicy); |
301 | 0 | } |
302 | 0 | } |
303 | 0 | else if (tagName == TRIGGERING_POLICY_TAG) |
304 | 0 | { |
305 | 0 | ObjectPtr policy(parseTriggeringPolicy(p, utf8Decoder, currentElement)); |
306 | 0 | RollingFileAppenderPtr rfa = LOG4CXX_NS::cast<RollingFileAppender>(appender); |
307 | 0 | TriggeringPolicyPtr policyPtr = LOG4CXX_NS::cast<TriggeringPolicy>(policy); |
308 | |
|
309 | 0 | if (rfa != NULL) |
310 | 0 | { |
311 | 0 | rfa->setTriggeringPolicy(policyPtr); |
312 | 0 | } |
313 | 0 | else |
314 | 0 | { |
315 | 0 | auto smtpa = LOG4CXX_NS::cast<LOG4CXX_NS::net::SMTPAppender>(appender); |
316 | |
|
317 | 0 | if (smtpa != NULL) |
318 | 0 | { |
319 | 0 | auto evaluator = LOG4CXX_NS::cast<TriggeringEventEvaluator>(policy); |
320 | 0 | smtpa->setEvaluator(evaluator); |
321 | 0 | } |
322 | 0 | } |
323 | 0 | } |
324 | 0 | else if (tagName == APPENDER_REF_TAG) |
325 | 0 | { |
326 | 0 | if (appender->instanceof(AppenderAttachable::getStaticClass())) |
327 | 0 | { |
328 | 0 | AppenderAttachablePtr aa = LOG4CXX_NS::cast<AppenderAttachable>(appender); |
329 | 0 | if (auto delegateAppender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders)) |
330 | 0 | { |
331 | 0 | if (LogLog::isDebugEnabled()) |
332 | 0 | { |
333 | 0 | LogLog::debug(LOG4CXX_STR("Attaching ") + Appender::getStaticClass().getName() |
334 | 0 | + LOG4CXX_STR(" named [") + delegateAppender->getName() + LOG4CXX_STR("] to ") + Appender::getStaticClass().getName() |
335 | 0 | + LOG4CXX_STR(" named [") + appender->getName() + LOG4CXX_STR("]")); |
336 | 0 | } |
337 | 0 | aa->addAppender(delegateAppender); |
338 | 0 | } |
339 | 0 | } |
340 | 0 | else |
341 | 0 | { |
342 | 0 | LogLog::error(LOG4CXX_STR("Cannot attach to ") + Appender::getStaticClass().getName() |
343 | 0 | + LOG4CXX_STR(" named [") + appender->getName() + LOG4CXX_STR("]") |
344 | 0 | + LOG4CXX_STR(" which does not implement ") + AppenderAttachable::getStaticClass().getName()); |
345 | 0 | } |
346 | 0 | } |
347 | 0 | } |
348 | |
|
349 | 0 | propSetter.activate(p); |
350 | 0 | return appender; |
351 | 0 | } |
352 | | /* Yes, it's ugly. But all of these exceptions point to the same |
353 | | problem: we can't create an Appender */ |
354 | 0 | catch (Exception& oops) |
355 | 0 | { |
356 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + Appender::getStaticClass().getName() + LOG4CXX_STR(" sub-class"), oops); |
357 | 0 | return 0; |
358 | 0 | } |
359 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseAppender(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseAppender(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
360 | | |
361 | | /** |
362 | | Used internally to parse an {@link ErrorHandler} element. |
363 | | */ |
364 | | void DOMConfigurator::parseErrorHandler(Pool& p, |
365 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
366 | | apr_xml_elem* element, |
367 | | AppenderPtr& appender, |
368 | | apr_xml_doc* doc, |
369 | | AppenderMap& appenders) |
370 | 0 | { |
371 | |
|
372 | 0 | ErrorHandlerPtr eh; |
373 | 0 | std::shared_ptr<Object> obj = OptionConverter::instantiateByClassName( |
374 | 0 | subst(getAttribute(utf8Decoder, element, CLASS_ATTR)), |
375 | 0 | ErrorHandler::getStaticClass(), |
376 | 0 | 0); |
377 | 0 | eh = LOG4CXX_NS::cast<ErrorHandler>(obj); |
378 | |
|
379 | 0 | if (eh != 0) |
380 | 0 | { |
381 | 0 | eh->setAppender(appender); |
382 | |
|
383 | 0 | PropertySetter propSetter(eh); |
384 | |
|
385 | 0 | for (apr_xml_elem* currentElement = element->first_child; |
386 | 0 | currentElement; |
387 | 0 | currentElement = currentElement->next) |
388 | 0 | { |
389 | 0 | std::string tagName(currentElement->name); |
390 | |
|
391 | 0 | if (tagName == PARAM_TAG) |
392 | 0 | { |
393 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
394 | 0 | } |
395 | 0 | else if (tagName == APPENDER_REF_TAG) |
396 | 0 | { |
397 | 0 | if (auto appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders)) |
398 | 0 | eh->setBackupAppender(appender); |
399 | 0 | } |
400 | 0 | else if (tagName == LOGGER_REF) |
401 | 0 | { |
402 | 0 | LogString loggerName(getAttribute(utf8Decoder, currentElement, REF_ATTR)); |
403 | 0 | LoggerPtr logger = m_priv->repository->getLogger(loggerName, m_priv->loggerFactory); |
404 | 0 | eh->setLogger(logger); |
405 | 0 | } |
406 | 0 | else if (tagName == ROOT_REF) |
407 | 0 | { |
408 | 0 | LoggerPtr root = m_priv->repository->getRootLogger(); |
409 | 0 | eh->setLogger(root); |
410 | 0 | } |
411 | 0 | } |
412 | |
|
413 | 0 | propSetter.activate(p); |
414 | 0 | std::shared_ptr<AppenderSkeleton> appSkeleton = LOG4CXX_NS::cast<AppenderSkeleton>(appender); |
415 | |
|
416 | 0 | if (appSkeleton != 0) |
417 | 0 | { |
418 | 0 | appSkeleton->setErrorHandler(eh); |
419 | 0 | } |
420 | 0 | } |
421 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseErrorHandler(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::shared_ptr<log4cxx::Appender>&, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseErrorHandler(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::shared_ptr<log4cxx::Appender>&, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
422 | | |
423 | | /** |
424 | | Used internally to parse a filter element. |
425 | | */ |
426 | | void DOMConfigurator::parseFilters(Pool& p, |
427 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
428 | | apr_xml_elem* element, |
429 | | std::vector<LOG4CXX_NS::spi::FilterPtr>& filters) |
430 | 0 | { |
431 | 0 | LogString clazz = subst(getAttribute(utf8Decoder, element, CLASS_ATTR)); |
432 | 0 | FilterPtr filter; |
433 | 0 | std::shared_ptr<Object> obj = OptionConverter::instantiateByClassName(clazz, |
434 | 0 | Filter::getStaticClass(), 0); |
435 | 0 | filter = LOG4CXX_NS::cast<Filter>(obj); |
436 | |
|
437 | 0 | if (filter != 0) |
438 | 0 | { |
439 | 0 | PropertySetter propSetter(filter); |
440 | |
|
441 | 0 | for (apr_xml_elem* currentElement = element->first_child; |
442 | 0 | currentElement; |
443 | 0 | currentElement = currentElement->next) |
444 | 0 | { |
445 | 0 | std::string tagName(currentElement->name); |
446 | |
|
447 | 0 | if (tagName == PARAM_TAG) |
448 | 0 | { |
449 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
450 | 0 | } |
451 | 0 | } |
452 | |
|
453 | 0 | propSetter.activate(p); |
454 | 0 | filters.push_back(filter); |
455 | 0 | } |
456 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseFilters(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::vector<std::__1::shared_ptr<log4cxx::spi::Filter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::spi::Filter> > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseFilters(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::vector<std::__1::shared_ptr<log4cxx::spi::Filter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::spi::Filter> > >&) |
457 | | |
458 | | /** |
459 | | Used internally to parse an category or logger element. |
460 | | */ |
461 | | void DOMConfigurator::parseLogger( |
462 | | LOG4CXX_NS::helpers::Pool& p, |
463 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
464 | | apr_xml_elem* loggerElement, |
465 | | apr_xml_doc* doc, |
466 | | AppenderMap& appenders) |
467 | 0 | { |
468 | | // Create a new Logger object from the <category> element. |
469 | 0 | LogString loggerName = subst(getAttribute(utf8Decoder, loggerElement, NAME_ATTR)); |
470 | |
|
471 | 0 | if (LogLog::isDebugEnabled()) |
472 | 0 | { |
473 | 0 | LogLog::debug(LOG4CXX_STR("Getting [") + loggerName + LOG4CXX_STR("]")); |
474 | 0 | } |
475 | 0 | LoggerPtr logger = m_priv->repository->getLogger(loggerName, m_priv->loggerFactory); |
476 | | |
477 | | // Setting up a logger needs to be an atomic operation, in order |
478 | | // to protect potential log operations while logger |
479 | | // configuration is in progress. |
480 | 0 | bool additivity = OptionConverter::toBoolean( |
481 | 0 | subst(getAttribute(utf8Decoder, loggerElement, ADDITIVITY_ATTR)), |
482 | 0 | true); |
483 | |
|
484 | 0 | if (LogLog::isDebugEnabled()) |
485 | 0 | { |
486 | 0 | LogLog::debug(LOG4CXX_STR("Setting [") + logger->getName() + LOG4CXX_STR("] additivity to [") + |
487 | 0 | (additivity ? LogString(LOG4CXX_STR("true")) : LogString(LOG4CXX_STR("false"))) + LOG4CXX_STR("]")); |
488 | 0 | } |
489 | 0 | logger->setAdditivity(additivity); |
490 | 0 | parseChildrenOfLoggerElement(p, utf8Decoder, loggerElement, logger, false, doc, appenders); |
491 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLogger(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLogger(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
492 | | |
493 | | /** |
494 | | Used internally to parse the logger factory element. |
495 | | */ |
496 | | void DOMConfigurator::parseLoggerFactory( |
497 | | LOG4CXX_NS::helpers::Pool& p, |
498 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
499 | | apr_xml_elem* factoryElement) |
500 | 0 | { |
501 | 0 | LogString className(subst(getAttribute(utf8Decoder, factoryElement, CLASS_ATTR))); |
502 | |
|
503 | 0 | if (className.empty()) |
504 | 0 | { |
505 | 0 | LogString msg(LOG4CXX_STR("[")); |
506 | 0 | utf8Decoder->decode(factoryElement->name, MAX_ATTRIBUTE_NAME_LEN, msg); |
507 | 0 | msg += LOG4CXX_STR("] attribute ["); |
508 | 0 | utf8Decoder->decode(CLASS_ATTR, MAX_ATTRIBUTE_NAME_LEN, msg); |
509 | 0 | msg += LOG4CXX_STR("] not found"); |
510 | 0 | LogLog::warn(msg); |
511 | 0 | } |
512 | 0 | else |
513 | 0 | { |
514 | 0 | auto obj = OptionConverter::instantiateByClassName |
515 | 0 | ( StringHelper::trim(className) |
516 | 0 | , LoggerFactory::getStaticClass() |
517 | 0 | #if LOG4CXX_ABI_VERSION <= 15 |
518 | 0 | , std::make_shared<DefaultLoggerFactory>() |
519 | | #else |
520 | | , std::make_shared<LoggerFactory>() |
521 | | #endif |
522 | 0 | ); |
523 | 0 | m_priv->loggerFactory = LOG4CXX_NS::cast<LoggerFactory>(obj); |
524 | 0 | PropertySetter propSetter(m_priv->loggerFactory); |
525 | |
|
526 | 0 | for (apr_xml_elem* currentElement = factoryElement->first_child; |
527 | 0 | currentElement; |
528 | 0 | currentElement = currentElement->next) |
529 | 0 | { |
530 | 0 | std::string tagName(currentElement->name); |
531 | |
|
532 | 0 | if (tagName == PARAM_TAG) |
533 | 0 | { |
534 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
535 | 0 | } |
536 | 0 | } |
537 | 0 | } |
538 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLoggerFactory(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLoggerFactory(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) |
539 | | |
540 | | /** |
541 | | Used internally to parse the root logger element. |
542 | | */ |
543 | | void DOMConfigurator::parseRoot( |
544 | | LOG4CXX_NS::helpers::Pool& p, |
545 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
546 | | apr_xml_elem* rootElement, |
547 | | apr_xml_doc* doc, |
548 | | AppenderMap& appenders) |
549 | 0 | { |
550 | 0 | LoggerPtr root = m_priv->repository->getRootLogger(); |
551 | 0 | parseChildrenOfLoggerElement(p, utf8Decoder, rootElement, root, true, doc, appenders); |
552 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseRoot(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseRoot(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
553 | | |
554 | | /** |
555 | | Used internally to parse the children of a logger element. |
556 | | */ |
557 | | void DOMConfigurator::parseChildrenOfLoggerElement( |
558 | | LOG4CXX_NS::helpers::Pool& p, |
559 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
560 | | apr_xml_elem* loggerElement, LoggerPtr logger, bool isRoot, |
561 | | apr_xml_doc* doc, |
562 | | AppenderMap& appenders) |
563 | 0 | { |
564 | 0 | PropertySetter propSetter(logger); |
565 | 0 | auto loggerName = m_priv->repository->getRootLogger() == logger |
566 | 0 | ? LogString(LOG4CXX_STR("root")) |
567 | 0 | : logger->getName(); |
568 | 0 | AsyncAppenderPtr async; |
569 | 0 | auto lsAsynchronous = subst(getAttribute(utf8Decoder, loggerElement, ASYNCHRONOUS_ATTR)); |
570 | 0 | if (!lsAsynchronous.empty() && OptionConverter::toBoolean(lsAsynchronous, true)) |
571 | 0 | { |
572 | 0 | async = std::make_shared<AsyncAppender>(); |
573 | 0 | async->setName(loggerName); |
574 | 0 | } |
575 | |
|
576 | 0 | std::vector<AppenderPtr> newappenders; |
577 | 0 | for (apr_xml_elem* currentElement = loggerElement->first_child; |
578 | 0 | currentElement; |
579 | 0 | currentElement = currentElement->next) |
580 | 0 | { |
581 | 0 | std::string tagName(currentElement->name); |
582 | |
|
583 | 0 | if (tagName == APPENDER_REF_TAG) |
584 | 0 | { |
585 | 0 | if (auto appender = findAppenderByReference(p, utf8Decoder, currentElement, doc, appenders)) |
586 | 0 | { |
587 | 0 | if (log4cxx::cast<AsyncAppender>(appender)) // An explicitly configured AsyncAppender? |
588 | 0 | async.reset(); // Not required |
589 | 0 | if (LogLog::isDebugEnabled()) |
590 | 0 | { |
591 | 0 | LogLog::debug(LOG4CXX_STR("Adding ") + Appender::getStaticClass().getName() |
592 | 0 | + LOG4CXX_STR(" named [") + appender->getName() + LOG4CXX_STR("]") |
593 | 0 | + LOG4CXX_STR(" to logger [") + logger->getName() + LOG4CXX_STR("]")); |
594 | 0 | } |
595 | 0 | newappenders.push_back(appender); |
596 | 0 | if (async) |
597 | 0 | async->addAppender(appender); |
598 | 0 | } |
599 | 0 | } |
600 | 0 | else if (tagName == LEVEL_TAG) |
601 | 0 | { |
602 | 0 | parseLevel(p, utf8Decoder, currentElement, logger, isRoot); |
603 | 0 | } |
604 | 0 | else if (tagName == PRIORITY_TAG) |
605 | 0 | { |
606 | 0 | parseLevel(p, utf8Decoder, currentElement, logger, isRoot); |
607 | 0 | } |
608 | 0 | else if (tagName == PARAM_TAG) |
609 | 0 | { |
610 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
611 | 0 | } |
612 | 0 | } |
613 | 0 | if (async && !newappenders.empty()) |
614 | 0 | { |
615 | 0 | if (LogLog::isDebugEnabled()) |
616 | 0 | { |
617 | 0 | LogLog::debug(LOG4CXX_STR("Asynchronous logging for [") |
618 | 0 | + logger->getName() + LOG4CXX_STR("] is on")); |
619 | 0 | } |
620 | 0 | logger->replaceAppenders({async}); |
621 | 0 | m_priv->appenderAdded = true; |
622 | 0 | } |
623 | 0 | else if (newappenders.empty()) |
624 | 0 | logger->removeAllAppenders(); |
625 | 0 | else |
626 | 0 | { |
627 | 0 | logger->replaceAppenders(newappenders); |
628 | 0 | m_priv->appenderAdded = true; |
629 | 0 | } |
630 | 0 | propSetter.activate(p); |
631 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseChildrenOfLoggerElement(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::shared_ptr<log4cxx::Logger>, bool, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseChildrenOfLoggerElement(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, std::__1::shared_ptr<log4cxx::Logger>, bool, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) |
632 | | |
633 | | /** |
634 | | Used internally to parse a layout element. |
635 | | */ |
636 | | LayoutPtr DOMConfigurator::parseLayout ( |
637 | | LOG4CXX_NS::helpers::Pool& p, |
638 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
639 | | apr_xml_elem* layout_element) |
640 | 0 | { |
641 | 0 | LogString className(subst(getAttribute(utf8Decoder, layout_element, CLASS_ATTR))); |
642 | 0 | if (LogLog::isDebugEnabled()) |
643 | 0 | { |
644 | 0 | LogLog::debug(LOG4CXX_STR("Desired ") + Layout::getStaticClass().getName() |
645 | 0 | + LOG4CXX_STR(" sub-class: [") + className + LOG4CXX_STR("]")); |
646 | 0 | } |
647 | |
|
648 | 0 | try |
649 | 0 | { |
650 | 0 | ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance()); |
651 | 0 | LayoutPtr layout = LOG4CXX_NS::cast<Layout>(instance); |
652 | 0 | PropertySetter propSetter(layout); |
653 | |
|
654 | 0 | for (apr_xml_elem* currentElement = layout_element->first_child; |
655 | 0 | currentElement; |
656 | 0 | currentElement = currentElement->next) |
657 | 0 | { |
658 | 0 | std::string tagName(currentElement->name); |
659 | |
|
660 | 0 | if (tagName == PARAM_TAG) |
661 | 0 | { |
662 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
663 | 0 | } |
664 | 0 | } |
665 | |
|
666 | 0 | propSetter.activate(p); |
667 | 0 | return layout; |
668 | 0 | } |
669 | 0 | catch (Exception& oops) |
670 | 0 | { |
671 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + Layout::getStaticClass().getName() + LOG4CXX_STR(" sub-class"), oops); |
672 | 0 | return 0; |
673 | 0 | } |
674 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLayout(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseLayout(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) |
675 | | |
676 | | /** |
677 | | Used internally to parse a triggering policy |
678 | | */ |
679 | | ObjectPtr DOMConfigurator::parseTriggeringPolicy ( |
680 | | LOG4CXX_NS::helpers::Pool& p, |
681 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
682 | | apr_xml_elem* policy_element) |
683 | 0 | { |
684 | 0 | LogString className = subst(getAttribute(utf8Decoder, policy_element, CLASS_ATTR)); |
685 | 0 | if (LogLog::isDebugEnabled()) |
686 | 0 | { |
687 | 0 | LogLog::debug(LOG4CXX_STR("Desired ") + TriggeringPolicy::getStaticClass().getName() |
688 | 0 | + LOG4CXX_STR(" sub-class: [") + className + LOG4CXX_STR("]")); |
689 | 0 | } |
690 | |
|
691 | 0 | try |
692 | 0 | { |
693 | 0 | ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance()); |
694 | 0 | PropertySetter propSetter(instance); |
695 | |
|
696 | 0 | for (apr_xml_elem* currentElement = policy_element->first_child; |
697 | 0 | currentElement; |
698 | 0 | currentElement = currentElement->next) |
699 | 0 | { |
700 | 0 | std::string tagName(currentElement->name); |
701 | |
|
702 | 0 | if (tagName == PARAM_TAG) |
703 | 0 | { |
704 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
705 | 0 | } |
706 | 0 | else if (tagName == FILTER_TAG) |
707 | 0 | { |
708 | 0 | std::vector<LOG4CXX_NS::spi::FilterPtr> filters; |
709 | 0 | parseFilters(p, utf8Decoder, currentElement, filters); |
710 | 0 | FilterBasedTriggeringPolicyPtr fbtp = LOG4CXX_NS::cast<FilterBasedTriggeringPolicy>(instance); |
711 | |
|
712 | 0 | if (fbtp != NULL) |
713 | 0 | { |
714 | 0 | for (auto& item : filters) |
715 | 0 | { |
716 | 0 | fbtp->addFilter(item); |
717 | 0 | } |
718 | 0 | } |
719 | 0 | } |
720 | 0 | } |
721 | |
|
722 | 0 | propSetter.activate(p); |
723 | 0 | return instance; |
724 | 0 | } |
725 | 0 | catch (Exception& oops) |
726 | 0 | { |
727 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + TriggeringPolicy::getStaticClass().getName() + LOG4CXX_STR(" sub-class"), oops); |
728 | 0 | return 0; |
729 | 0 | } |
730 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseTriggeringPolicy(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseTriggeringPolicy(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) |
731 | | |
732 | | /** |
733 | | Used internally to parse a triggering policy |
734 | | */ |
735 | | RollingPolicyPtr DOMConfigurator::parseRollingPolicy ( |
736 | | LOG4CXX_NS::helpers::Pool& p, |
737 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
738 | | apr_xml_elem* policy_element) |
739 | 0 | { |
740 | 0 | LogString className = subst(getAttribute(utf8Decoder, policy_element, CLASS_ATTR)); |
741 | 0 | if (LogLog::isDebugEnabled()) |
742 | 0 | { |
743 | 0 | LogLog::debug(LOG4CXX_STR("Desired ") + RollingPolicy::getStaticClass().getName() |
744 | 0 | + LOG4CXX_STR(" sub-class: [") + className + LOG4CXX_STR("]")); |
745 | 0 | } |
746 | |
|
747 | 0 | try |
748 | 0 | { |
749 | 0 | ObjectPtr instance = ObjectPtr(Loader::loadClass(className).newInstance()); |
750 | 0 | PropertySetter propSetter(instance); |
751 | |
|
752 | 0 | for (apr_xml_elem* currentElement = policy_element->first_child; |
753 | 0 | currentElement; |
754 | 0 | currentElement = currentElement->next) |
755 | 0 | { |
756 | 0 | std::string tagName(currentElement->name); |
757 | |
|
758 | 0 | if (tagName == PARAM_TAG) |
759 | 0 | { |
760 | 0 | setParameter(p, utf8Decoder, currentElement, propSetter); |
761 | 0 | } |
762 | 0 | } |
763 | |
|
764 | 0 | propSetter.activate(p); |
765 | 0 | return LOG4CXX_NS::cast<RollingPolicy>(instance); |
766 | 0 | } |
767 | 0 | catch (Exception& oops) |
768 | 0 | { |
769 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + RollingPolicy::getStaticClass().getName() + LOG4CXX_STR(" sub-class"), oops); |
770 | 0 | return 0; |
771 | 0 | } |
772 | 0 | } Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseRollingPolicy(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) Unexecuted instantiation: log4cxx::xml::DOMConfigurator::parseRollingPolicy(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*) |
773 | | |
774 | | |
775 | | |
776 | | /** |
777 | | Used internally to parse a level element. |
778 | | */ |
779 | | void DOMConfigurator::parseLevel( |
780 | | LOG4CXX_NS::helpers::Pool& p, |
781 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
782 | | apr_xml_elem* element, LoggerPtr logger, bool isRoot) |
783 | 0 | { |
784 | 0 | LogString loggerName = logger->getName(); |
785 | |
|
786 | 0 | if (isRoot) |
787 | 0 | { |
788 | 0 | loggerName = LOG4CXX_STR("root"); |
789 | 0 | } |
790 | |
|
791 | 0 | LogString levelStr(subst(getAttribute(utf8Decoder, element, VALUE_ATTR))); |
792 | 0 | if (LogLog::isDebugEnabled()) |
793 | 0 | { |
794 | 0 | LogLog::debug(LOG4CXX_STR("Setting [") + loggerName + LOG4CXX_STR("] level to [") + levelStr + LOG4CXX_STR("]")); |
795 | 0 | } |
796 | |
|
797 | 0 | if (StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("INHERITED"), LOG4CXX_STR("inherited")) |
798 | 0 | || StringHelper::equalsIgnoreCase(levelStr, LOG4CXX_STR("NULL"), LOG4CXX_STR("null"))) |
799 | 0 | { |
800 | 0 | if (isRoot) |
801 | 0 | { |
802 | 0 | LogLog::error(LOG4CXX_STR("Root level cannot be ") + levelStr + LOG4CXX_STR(". Ignoring directive.")); |
803 | 0 | } |
804 | 0 | else |
805 | 0 | { |
806 | 0 | logger->setLevel(0); |
807 | 0 | } |
808 | 0 | } |
809 | 0 | else |
810 | 0 | { |
811 | 0 | LogString className(subst(getAttribute(utf8Decoder, element, CLASS_ATTR))); |
812 | |
|
813 | 0 | if (className.empty()) |
814 | 0 | { |
815 | 0 | logger->setLevel(OptionConverter::toLevel(levelStr, Level::getDebug())); |
816 | 0 | } |
817 | 0 | else |
818 | 0 | { |
819 | 0 | if (LogLog::isDebugEnabled()) |
820 | 0 | { |
821 | 0 | LogLog::debug(LOG4CXX_STR("Desired ") + Level::getStaticClass().getName() |
822 | 0 | + LOG4CXX_STR(" sub-class: [") + className + LOG4CXX_STR("]")); |
823 | 0 | } |
824 | |
|
825 | 0 | try |
826 | 0 | { |
827 | 0 | Level::LevelClass& levelClass = |
828 | 0 | (Level::LevelClass&)Loader::loadClass(className); |
829 | 0 | LevelPtr level = levelClass.toLevel(levelStr); |
830 | 0 | logger->setLevel(level); |
831 | 0 | } |
832 | 0 | catch (Exception& oops) |
833 | 0 | { |
834 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + Level::getStaticClass().getName() + LOG4CXX_STR(" sub-class"), oops); |
835 | 0 | return; |
836 | 0 | } |
837 | 0 | catch (...) |
838 | 0 | { |
839 | 0 | LogLog::error(LOG4CXX_STR("Could not create ") + Level::getStaticClass().getName() + LOG4CXX_STR(" sub-class") |
840 | 0 | + LOG4CXX_STR(" from [") + className |
841 | 0 | + LOG4CXX_STR("]")); |
842 | 0 | return; |
843 | 0 | } |
844 | 0 | } |
845 | 0 | } |
846 | | |
847 | 0 | if (LogLog::isDebugEnabled()) |
848 | 0 | { |
849 | 0 | LogLog::debug(LOG4CXX_STR("[") + loggerName + LOG4CXX_STR("] level is ") + |
850 | 0 | logger->getEffectiveLevel()->toString()); |
851 | 0 | } |
852 | 0 | } |
853 | | |
854 | | void DOMConfigurator::setParameter(LOG4CXX_NS::helpers::Pool& p, |
855 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
856 | | apr_xml_elem* elem, |
857 | | PropertySetter& propSetter) |
858 | 0 | { |
859 | 0 | LogString name(subst(getAttribute(utf8Decoder, elem, NAME_ATTR))); |
860 | 0 | LogString value(subst(getAttribute(utf8Decoder, elem, VALUE_ATTR))); |
861 | 0 | value = subst(value); |
862 | 0 | propSetter.setProperty(name, value, p); |
863 | 0 | } |
864 | | |
865 | | spi::ConfigurationStatus DOMConfigurator::doConfigure |
866 | | ( const File& filename |
867 | | #if LOG4CXX_ABI_VERSION <= 15 |
868 | | , spi::LoggerRepositoryPtr repository |
869 | | #else |
870 | | , const spi::LoggerRepositoryPtr& repository |
871 | | #endif |
872 | | ) |
873 | 8.76k | { |
874 | 8.76k | m_priv->repository = repository ? repository : LogManager::getLoggerRepository(); |
875 | | |
876 | 8.76k | #if LOG4CXX_ABI_VERSION <= 15 |
877 | 8.76k | m_priv->loggerFactory = std::make_shared<DefaultLoggerFactory>(); |
878 | | #else |
879 | | m_priv->loggerFactory = std::make_shared<LoggerFactory>(); |
880 | | #endif |
881 | | |
882 | 8.76k | Pool p; |
883 | 8.76k | apr_file_t* fd; |
884 | | |
885 | 8.76k | log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p); |
886 | | |
887 | 8.76k | if (rv != APR_SUCCESS) |
888 | 0 | { |
889 | 0 | LogLog::error(LOG4CXX_STR("Could not open configuration file [") |
890 | 0 | + filename.getPath() + LOG4CXX_STR("]") |
891 | 0 | , IOException(rv)); |
892 | 0 | return spi::ConfigurationStatus::NotConfigured; |
893 | 0 | } |
894 | 8.76k | else |
895 | 8.76k | { |
896 | 8.76k | apr_xml_parser* parser = NULL; |
897 | 8.76k | apr_xml_doc* doc = NULL; |
898 | | |
899 | 8.76k | if (LogLog::isDebugEnabled()) |
900 | 7.53k | { |
901 | 7.53k | LogLog::debug(LOG4CXX_STR("Loading configuration file [") |
902 | 7.53k | + filename.getPath() + LOG4CXX_STR("]")); |
903 | 7.53k | } |
904 | | |
905 | 8.76k | rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000); |
906 | | |
907 | 8.76k | if (rv != APR_SUCCESS) |
908 | 6.75k | { |
909 | 6.75k | LogString reason; |
910 | 6.75k | if (parser) |
911 | 890 | { |
912 | 890 | char errbuf[2000]; |
913 | 890 | apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf)); |
914 | 890 | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); |
915 | 890 | reason.append(lsErrbuf); |
916 | 890 | } |
917 | 5.86k | else |
918 | 5.86k | { |
919 | 5.86k | char errbuf[2000]; |
920 | 5.86k | apr_strerror(rv, errbuf, sizeof(errbuf)); |
921 | 5.86k | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); |
922 | 5.86k | reason.append(lsErrbuf); |
923 | 5.86k | } |
924 | 6.75k | LogLog::error(LOG4CXX_STR("Error parsing file [") |
925 | 6.75k | + filename.getPath() + LOG4CXX_STR("]") |
926 | 6.75k | , RuntimeException(reason)); |
927 | 6.75k | return spi::ConfigurationStatus::NotConfigured; |
928 | 6.75k | } |
929 | 2.00k | else |
930 | 2.00k | { |
931 | 2.00k | AppenderMap appenders; |
932 | 2.00k | CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder()); |
933 | 2.00k | parse(p, utf8Decoder, doc->root, doc, appenders); |
934 | 2.00k | } |
935 | 8.76k | } |
936 | | |
937 | 2.00k | if (!m_priv->appenderAdded) |
938 | 2.00k | { |
939 | 2.00k | LogLog::warn(LOG4CXX_STR("[") + filename.getPath() |
940 | 2.00k | + LOG4CXX_STR("] did not add an ") + Appender::getStaticClass().getName() |
941 | 2.00k | + LOG4CXX_STR(" to a logger")); |
942 | 2.00k | return spi::ConfigurationStatus::NotConfigured; |
943 | 2.00k | } |
944 | | |
945 | 0 | m_priv->repository->setConfigured(true); |
946 | 0 | return spi::ConfigurationStatus::Configured; |
947 | 2.00k | } log4cxx::xml::DOMConfigurator::doConfigure(log4cxx::File const&, std::__1::shared_ptr<log4cxx::spi::LoggerRepository>) Line | Count | Source | 873 | 4.38k | { | 874 | 4.38k | m_priv->repository = repository ? repository : LogManager::getLoggerRepository(); | 875 | | | 876 | 4.38k | #if LOG4CXX_ABI_VERSION <= 15 | 877 | 4.38k | m_priv->loggerFactory = std::make_shared<DefaultLoggerFactory>(); | 878 | | #else | 879 | | m_priv->loggerFactory = std::make_shared<LoggerFactory>(); | 880 | | #endif | 881 | | | 882 | 4.38k | Pool p; | 883 | 4.38k | apr_file_t* fd; | 884 | | | 885 | 4.38k | log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p); | 886 | | | 887 | 4.38k | if (rv != APR_SUCCESS) | 888 | 0 | { | 889 | 0 | LogLog::error(LOG4CXX_STR("Could not open configuration file [") | 890 | 0 | + filename.getPath() + LOG4CXX_STR("]") | 891 | 0 | , IOException(rv)); | 892 | 0 | return spi::ConfigurationStatus::NotConfigured; | 893 | 0 | } | 894 | 4.38k | else | 895 | 4.38k | { | 896 | 4.38k | apr_xml_parser* parser = NULL; | 897 | 4.38k | apr_xml_doc* doc = NULL; | 898 | | | 899 | 4.38k | if (LogLog::isDebugEnabled()) | 900 | 3.76k | { | 901 | 3.76k | LogLog::debug(LOG4CXX_STR("Loading configuration file [") | 902 | 3.76k | + filename.getPath() + LOG4CXX_STR("]")); | 903 | 3.76k | } | 904 | | | 905 | 4.38k | rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000); | 906 | | | 907 | 4.38k | if (rv != APR_SUCCESS) | 908 | 3.37k | { | 909 | 3.37k | LogString reason; | 910 | 3.37k | if (parser) | 911 | 445 | { | 912 | 445 | char errbuf[2000]; | 913 | 445 | apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf)); | 914 | 445 | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); | 915 | 445 | reason.append(lsErrbuf); | 916 | 445 | } | 917 | 2.93k | else | 918 | 2.93k | { | 919 | 2.93k | char errbuf[2000]; | 920 | 2.93k | apr_strerror(rv, errbuf, sizeof(errbuf)); | 921 | 2.93k | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); | 922 | 2.93k | reason.append(lsErrbuf); | 923 | 2.93k | } | 924 | 3.37k | LogLog::error(LOG4CXX_STR("Error parsing file [") | 925 | 3.37k | + filename.getPath() + LOG4CXX_STR("]") | 926 | 3.37k | , RuntimeException(reason)); | 927 | 3.37k | return spi::ConfigurationStatus::NotConfigured; | 928 | 3.37k | } | 929 | 1.00k | else | 930 | 1.00k | { | 931 | 1.00k | AppenderMap appenders; | 932 | 1.00k | CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder()); | 933 | 1.00k | parse(p, utf8Decoder, doc->root, doc, appenders); | 934 | 1.00k | } | 935 | 4.38k | } | 936 | | | 937 | 1.00k | if (!m_priv->appenderAdded) | 938 | 1.00k | { | 939 | 1.00k | LogLog::warn(LOG4CXX_STR("[") + filename.getPath() | 940 | 1.00k | + LOG4CXX_STR("] did not add an ") + Appender::getStaticClass().getName() | 941 | 1.00k | + LOG4CXX_STR(" to a logger")); | 942 | 1.00k | return spi::ConfigurationStatus::NotConfigured; | 943 | 1.00k | } | 944 | | | 945 | 0 | m_priv->repository->setConfigured(true); | 946 | 0 | return spi::ConfigurationStatus::Configured; | 947 | 1.00k | } |
log4cxx::xml::DOMConfigurator::doConfigure(log4cxx::File const&, std::__1::shared_ptr<log4cxx::spi::LoggerRepository>) Line | Count | Source | 873 | 4.38k | { | 874 | 4.38k | m_priv->repository = repository ? repository : LogManager::getLoggerRepository(); | 875 | | | 876 | 4.38k | #if LOG4CXX_ABI_VERSION <= 15 | 877 | 4.38k | m_priv->loggerFactory = std::make_shared<DefaultLoggerFactory>(); | 878 | | #else | 879 | | m_priv->loggerFactory = std::make_shared<LoggerFactory>(); | 880 | | #endif | 881 | | | 882 | 4.38k | Pool p; | 883 | 4.38k | apr_file_t* fd; | 884 | | | 885 | 4.38k | log4cxx_status_t rv = filename.open(&fd, APR_READ, APR_OS_DEFAULT, p); | 886 | | | 887 | 4.38k | if (rv != APR_SUCCESS) | 888 | 0 | { | 889 | 0 | LogLog::error(LOG4CXX_STR("Could not open configuration file [") | 890 | 0 | + filename.getPath() + LOG4CXX_STR("]") | 891 | 0 | , IOException(rv)); | 892 | 0 | return spi::ConfigurationStatus::NotConfigured; | 893 | 0 | } | 894 | 4.38k | else | 895 | 4.38k | { | 896 | 4.38k | apr_xml_parser* parser = NULL; | 897 | 4.38k | apr_xml_doc* doc = NULL; | 898 | | | 899 | 4.38k | if (LogLog::isDebugEnabled()) | 900 | 3.76k | { | 901 | 3.76k | LogLog::debug(LOG4CXX_STR("Loading configuration file [") | 902 | 3.76k | + filename.getPath() + LOG4CXX_STR("]")); | 903 | 3.76k | } | 904 | | | 905 | 4.38k | rv = apr_xml_parse_file(p.getAPRPool(), &parser, &doc, fd, 2000); | 906 | | | 907 | 4.38k | if (rv != APR_SUCCESS) | 908 | 3.37k | { | 909 | 3.37k | LogString reason; | 910 | 3.37k | if (parser) | 911 | 445 | { | 912 | 445 | char errbuf[2000]; | 913 | 445 | apr_xml_parser_geterror(parser, errbuf, sizeof(errbuf)); | 914 | 445 | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); | 915 | 445 | reason.append(lsErrbuf); | 916 | 445 | } | 917 | 2.93k | else | 918 | 2.93k | { | 919 | 2.93k | char errbuf[2000]; | 920 | 2.93k | apr_strerror(rv, errbuf, sizeof(errbuf)); | 921 | 2.93k | LOG4CXX_DECODE_CHAR(lsErrbuf, std::string(errbuf)); | 922 | 2.93k | reason.append(lsErrbuf); | 923 | 2.93k | } | 924 | 3.37k | LogLog::error(LOG4CXX_STR("Error parsing file [") | 925 | 3.37k | + filename.getPath() + LOG4CXX_STR("]") | 926 | 3.37k | , RuntimeException(reason)); | 927 | 3.37k | return spi::ConfigurationStatus::NotConfigured; | 928 | 3.37k | } | 929 | 1.00k | else | 930 | 1.00k | { | 931 | 1.00k | AppenderMap appenders; | 932 | 1.00k | CharsetDecoderPtr utf8Decoder(CharsetDecoder::getUTF8Decoder()); | 933 | 1.00k | parse(p, utf8Decoder, doc->root, doc, appenders); | 934 | 1.00k | } | 935 | 4.38k | } | 936 | | | 937 | 1.00k | if (!m_priv->appenderAdded) | 938 | 1.00k | { | 939 | 1.00k | LogLog::warn(LOG4CXX_STR("[") + filename.getPath() | 940 | 1.00k | + LOG4CXX_STR("] did not add an ") + Appender::getStaticClass().getName() | 941 | 1.00k | + LOG4CXX_STR(" to a logger")); | 942 | 1.00k | return spi::ConfigurationStatus::NotConfigured; | 943 | 1.00k | } | 944 | | | 945 | 0 | m_priv->repository->setConfigured(true); | 946 | 0 | return spi::ConfigurationStatus::Configured; | 947 | 1.00k | } |
|
948 | | |
949 | | // Read configuration options from \c filename. |
950 | | spi::ConfigurationStatus DOMConfigurator::configure(const File& filename) |
951 | 0 | { |
952 | 0 | return DOMConfigurator().doConfigure(filename, LogManager::getLoggerRepository()); |
953 | 0 | } |
954 | | |
955 | | #if LOG4CXX_ABI_VERSION <= 15 |
956 | | spi::ConfigurationStatus DOMConfigurator::configure(const std::string& filename) |
957 | 4.38k | { |
958 | 4.38k | File file(filename); |
959 | 4.38k | return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
960 | 4.38k | } |
961 | | |
962 | | #if LOG4CXX_WCHAR_T_API |
963 | | spi::ConfigurationStatus DOMConfigurator::configure(const std::wstring& filename) |
964 | 0 | { |
965 | 0 | File file(filename); |
966 | 0 | return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
967 | 0 | } |
968 | | #endif |
969 | | |
970 | | #if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR |
971 | | spi::ConfigurationStatus DOMConfigurator::configure(const std::basic_string<UniChar>& filename) |
972 | | { |
973 | | File file(filename); |
974 | | return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
975 | | } |
976 | | #endif |
977 | | |
978 | | #if LOG4CXX_CFSTRING_API |
979 | | spi::ConfigurationStatus DOMConfigurator::configure(const CFStringRef& filename) |
980 | | { |
981 | | File file(filename); |
982 | | return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
983 | | } |
984 | | #endif |
985 | | |
986 | | |
987 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::string& filename) |
988 | 0 | { |
989 | 0 | return configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY); |
990 | 0 | } |
991 | | |
992 | | #if LOG4CXX_WCHAR_T_API |
993 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::wstring& filename) |
994 | 0 | { |
995 | 0 | return configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY); |
996 | 0 | } |
997 | | #endif |
998 | | |
999 | | #if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR |
1000 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename) |
1001 | | { |
1002 | | return configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY); |
1003 | | } |
1004 | | #endif |
1005 | | |
1006 | | #if LOG4CXX_CFSTRING_API |
1007 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& filename) |
1008 | | { |
1009 | | return configureAndWatch(filename, FileWatchdog::DEFAULT_DELAY); |
1010 | | } |
1011 | | #endif |
1012 | | |
1013 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::string& filename, long delay) |
1014 | 0 | { |
1015 | 0 | return configureAndWatch(File(filename), delay); |
1016 | 0 | } |
1017 | | #endif // LOG4CXX_ABI_VERSION <= 15 |
1018 | | |
1019 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const File& file, long delay) |
1020 | 0 | { |
1021 | 0 | spi::ConfigurationStatus status = DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
1022 | 0 | XMLWatchdog::startWatching(file, delay); |
1023 | 0 | return status; |
1024 | 0 | } |
1025 | | |
1026 | | #if LOG4CXX_ABI_VERSION <= 15 |
1027 | | #if LOG4CXX_WCHAR_T_API |
1028 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::wstring& filename, long delay) |
1029 | 0 | { |
1030 | 0 | File file(filename); |
1031 | 0 | spi::ConfigurationStatus status = DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
1032 | 0 | XMLWatchdog::startWatching(file, delay); |
1033 | 0 | return status; |
1034 | 0 | } |
1035 | | #endif |
1036 | | |
1037 | | #if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR |
1038 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename, long delay) |
1039 | | { |
1040 | | File file(filename); |
1041 | | spi::ConfigurationStatus status = DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
1042 | | XMLWatchdog::startWatching(file, delay); |
1043 | | return status; |
1044 | | } |
1045 | | #endif |
1046 | | |
1047 | | #if LOG4CXX_CFSTRING_API |
1048 | | spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& filename, long delay) |
1049 | | { |
1050 | | File file(filename); |
1051 | | spi::ConfigurationStatus status = DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository()); |
1052 | | XMLWatchdog::startWatching(file, delay); |
1053 | | return status; |
1054 | | } |
1055 | | #endif |
1056 | | #endif // LOG4CXX_ABI_VERSION <= 15 |
1057 | | |
1058 | | void DOMConfigurator::parse( |
1059 | | Pool& p, |
1060 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
1061 | | apr_xml_elem* element, |
1062 | | apr_xml_doc* doc, |
1063 | | AppenderMap& appenders) |
1064 | 1.00k | { |
1065 | 1.00k | std::string rootElementName(element->name); |
1066 | | |
1067 | 1.00k | if (rootElementName != CONFIGURATION_TAG) |
1068 | 1.00k | { |
1069 | 1.00k | if (rootElementName == OLD_CONFIGURATION_TAG) |
1070 | 842 | { |
1071 | | //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+ |
1072 | | // LOG4CXX_STR("> element has been deprecated.")); |
1073 | | //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+ |
1074 | | // LOG4CXX_STR("> element instead.")); |
1075 | 842 | } |
1076 | 160 | else |
1077 | 160 | { |
1078 | 160 | LogString msg(LOG4CXX_STR("Root element [")); |
1079 | 160 | utf8Decoder->decode(element->name, MAX_ATTRIBUTE_NAME_LEN, msg); |
1080 | 160 | msg += LOG4CXX_STR("] is not ["); |
1081 | 160 | utf8Decoder->decode(CONFIGURATION_TAG, MAX_ATTRIBUTE_NAME_LEN, msg); |
1082 | 160 | msg += LOG4CXX_STR("]"); |
1083 | 160 | LogLog::error(msg); |
1084 | 160 | return; |
1085 | 160 | } |
1086 | 1.00k | } |
1087 | | |
1088 | 842 | LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR)); |
1089 | | |
1090 | | // if the log4j.dtd is not specified in the XML file, then the |
1091 | | // "debug" attribute is returned as the empty string. |
1092 | 842 | if (!debugAttrib.empty() && debugAttrib != LOG4CXX_STR("NULL")) |
1093 | 294 | { |
1094 | 294 | LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true)); |
1095 | 294 | } |
1096 | | |
1097 | 842 | LogString colorAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_COLOR_ATTR)); |
1098 | 842 | if (!colorAttrib.empty()) |
1099 | 53 | { |
1100 | 53 | LogLog::setColorEnabled(OptionConverter::toBoolean(colorAttrib, true)); |
1101 | 53 | } |
1102 | | |
1103 | 842 | LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR)); |
1104 | | |
1105 | 842 | if (!thresholdStr.empty() && thresholdStr != LOG4CXX_STR("NULL")) |
1106 | 351 | { |
1107 | 351 | m_priv->repository->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll())); |
1108 | 351 | if (LogLog::isDebugEnabled()) |
1109 | 346 | { |
1110 | 346 | LogLog::debug(LOG4CXX_STR("Repository threshold =[") |
1111 | 346 | + m_priv->repository->getThreshold()->toString() |
1112 | 346 | + LOG4CXX_STR("]")); |
1113 | 346 | } |
1114 | 351 | } |
1115 | | |
1116 | 842 | LogString threadSignalValue = subst(getAttribute(utf8Decoder, element, THREAD_CONFIG_ATTR)); |
1117 | | |
1118 | 842 | if ( !threadSignalValue.empty() && threadSignalValue != LOG4CXX_STR("NULL") ) |
1119 | 110 | { |
1120 | 110 | if (LogLog::isDebugEnabled()) |
1121 | 108 | { |
1122 | 108 | LogLog::debug(LOG4CXX_STR("ThreadUtility configuration =[") + threadSignalValue + LOG4CXX_STR("]")); |
1123 | 108 | } |
1124 | 110 | if ( threadSignalValue == LOG4CXX_STR("NoConfiguration") ) |
1125 | 0 | { |
1126 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NoConfiguration ); |
1127 | 0 | } |
1128 | 110 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsOnly") ) |
1129 | 0 | { |
1130 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsOnly ); |
1131 | 0 | } |
1132 | 110 | else if ( threadSignalValue == LOG4CXX_STR("NameThreadOnly") ) |
1133 | 0 | { |
1134 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NameThreadOnly ); |
1135 | 0 | } |
1136 | 110 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsAndNameThread") ) |
1137 | 0 | { |
1138 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsAndNameThread ); |
1139 | 0 | } |
1140 | 110 | else |
1141 | 110 | { |
1142 | 110 | LogLog::warn(LOG4CXX_STR("threadConfiguration value [") + threadSignalValue + LOG4CXX_STR("]") + LOG4CXX_STR(" is not valid")); |
1143 | 110 | } |
1144 | 110 | } |
1145 | | |
1146 | 842 | apr_xml_elem* currentElement; |
1147 | | |
1148 | 842 | for (currentElement = element->first_child; |
1149 | 842 | currentElement; |
1150 | 842 | currentElement = currentElement->next) |
1151 | 0 | { |
1152 | 0 | std::string tagName(currentElement->name); |
1153 | |
|
1154 | 0 | if (tagName == CATEGORY_FACTORY_TAG) |
1155 | 0 | { |
1156 | 0 | parseLoggerFactory(p, utf8Decoder, currentElement); |
1157 | 0 | } |
1158 | 0 | } |
1159 | | |
1160 | 842 | for (currentElement = element->first_child; |
1161 | 842 | currentElement; |
1162 | 842 | currentElement = currentElement->next) |
1163 | 0 | { |
1164 | 0 | std::string tagName(currentElement->name); |
1165 | |
|
1166 | 0 | if (tagName == CATEGORY || tagName == LOGGER) |
1167 | 0 | { |
1168 | 0 | parseLogger(p, utf8Decoder, currentElement, doc, appenders); |
1169 | 0 | } |
1170 | 0 | else if (tagName == ROOT_TAG) |
1171 | 0 | { |
1172 | 0 | parseRoot(p, utf8Decoder, currentElement, doc, appenders); |
1173 | 0 | } |
1174 | 0 | } |
1175 | 842 | } log4cxx::xml::DOMConfigurator::parse(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Line | Count | Source | 1064 | 539 | { | 1065 | 539 | std::string rootElementName(element->name); | 1066 | | | 1067 | 539 | if (rootElementName != CONFIGURATION_TAG) | 1068 | 539 | { | 1069 | 539 | if (rootElementName == OLD_CONFIGURATION_TAG) | 1070 | 448 | { | 1071 | | //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+ | 1072 | | // LOG4CXX_STR("> element has been deprecated.")); | 1073 | | //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+ | 1074 | | // LOG4CXX_STR("> element instead.")); | 1075 | 448 | } | 1076 | 91 | else | 1077 | 91 | { | 1078 | 91 | LogString msg(LOG4CXX_STR("Root element [")); | 1079 | 91 | utf8Decoder->decode(element->name, MAX_ATTRIBUTE_NAME_LEN, msg); | 1080 | 91 | msg += LOG4CXX_STR("] is not ["); | 1081 | 91 | utf8Decoder->decode(CONFIGURATION_TAG, MAX_ATTRIBUTE_NAME_LEN, msg); | 1082 | 91 | msg += LOG4CXX_STR("]"); | 1083 | 91 | LogLog::error(msg); | 1084 | 91 | return; | 1085 | 91 | } | 1086 | 539 | } | 1087 | | | 1088 | 448 | LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR)); | 1089 | | | 1090 | | // if the log4j.dtd is not specified in the XML file, then the | 1091 | | // "debug" attribute is returned as the empty string. | 1092 | 448 | if (!debugAttrib.empty() && debugAttrib != LOG4CXX_STR("NULL")) | 1093 | 150 | { | 1094 | 150 | LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true)); | 1095 | 150 | } | 1096 | | | 1097 | 448 | LogString colorAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_COLOR_ATTR)); | 1098 | 448 | if (!colorAttrib.empty()) | 1099 | 29 | { | 1100 | 29 | LogLog::setColorEnabled(OptionConverter::toBoolean(colorAttrib, true)); | 1101 | 29 | } | 1102 | | | 1103 | 448 | LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR)); | 1104 | | | 1105 | 448 | if (!thresholdStr.empty() && thresholdStr != LOG4CXX_STR("NULL")) | 1106 | 190 | { | 1107 | 190 | m_priv->repository->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll())); | 1108 | 190 | if (LogLog::isDebugEnabled()) | 1109 | 188 | { | 1110 | 188 | LogLog::debug(LOG4CXX_STR("Repository threshold =[") | 1111 | 188 | + m_priv->repository->getThreshold()->toString() | 1112 | 188 | + LOG4CXX_STR("]")); | 1113 | 188 | } | 1114 | 190 | } | 1115 | | | 1116 | 448 | LogString threadSignalValue = subst(getAttribute(utf8Decoder, element, THREAD_CONFIG_ATTR)); | 1117 | | | 1118 | 448 | if ( !threadSignalValue.empty() && threadSignalValue != LOG4CXX_STR("NULL") ) | 1119 | 59 | { | 1120 | 59 | if (LogLog::isDebugEnabled()) | 1121 | 58 | { | 1122 | 58 | LogLog::debug(LOG4CXX_STR("ThreadUtility configuration =[") + threadSignalValue + LOG4CXX_STR("]")); | 1123 | 58 | } | 1124 | 59 | if ( threadSignalValue == LOG4CXX_STR("NoConfiguration") ) | 1125 | 0 | { | 1126 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NoConfiguration ); | 1127 | 0 | } | 1128 | 59 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsOnly") ) | 1129 | 0 | { | 1130 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsOnly ); | 1131 | 0 | } | 1132 | 59 | else if ( threadSignalValue == LOG4CXX_STR("NameThreadOnly") ) | 1133 | 0 | { | 1134 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NameThreadOnly ); | 1135 | 0 | } | 1136 | 59 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsAndNameThread") ) | 1137 | 0 | { | 1138 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsAndNameThread ); | 1139 | 0 | } | 1140 | 59 | else | 1141 | 59 | { | 1142 | 59 | LogLog::warn(LOG4CXX_STR("threadConfiguration value [") + threadSignalValue + LOG4CXX_STR("]") + LOG4CXX_STR(" is not valid")); | 1143 | 59 | } | 1144 | 59 | } | 1145 | | | 1146 | 448 | apr_xml_elem* currentElement; | 1147 | | | 1148 | 448 | for (currentElement = element->first_child; | 1149 | 448 | currentElement; | 1150 | 448 | currentElement = currentElement->next) | 1151 | 0 | { | 1152 | 0 | std::string tagName(currentElement->name); | 1153 | |
| 1154 | 0 | if (tagName == CATEGORY_FACTORY_TAG) | 1155 | 0 | { | 1156 | 0 | parseLoggerFactory(p, utf8Decoder, currentElement); | 1157 | 0 | } | 1158 | 0 | } | 1159 | | | 1160 | 448 | for (currentElement = element->first_child; | 1161 | 448 | currentElement; | 1162 | 448 | currentElement = currentElement->next) | 1163 | 0 | { | 1164 | 0 | std::string tagName(currentElement->name); | 1165 | |
| 1166 | 0 | if (tagName == CATEGORY || tagName == LOGGER) | 1167 | 0 | { | 1168 | 0 | parseLogger(p, utf8Decoder, currentElement, doc, appenders); | 1169 | 0 | } | 1170 | 0 | else if (tagName == ROOT_TAG) | 1171 | 0 | { | 1172 | 0 | parseRoot(p, utf8Decoder, currentElement, doc, appenders); | 1173 | 0 | } | 1174 | 0 | } | 1175 | 448 | } |
log4cxx::xml::DOMConfigurator::parse(log4cxx::helpers::Pool&, std::__1::shared_ptr<log4cxx::helpers::CharsetDecoder>&, apr_xml_elem*, apr_xml_doc*, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::shared_ptr<log4cxx::Appender>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::shared_ptr<log4cxx::Appender> > > >&) Line | Count | Source | 1064 | 463 | { | 1065 | 463 | std::string rootElementName(element->name); | 1066 | | | 1067 | 463 | if (rootElementName != CONFIGURATION_TAG) | 1068 | 463 | { | 1069 | 463 | if (rootElementName == OLD_CONFIGURATION_TAG) | 1070 | 394 | { | 1071 | | //LogLog::warn(LOG4CXX_STR("The <")+String(OLD_CONFIGURATION_TAG)+ | 1072 | | // LOG4CXX_STR("> element has been deprecated.")); | 1073 | | //LogLog::warn(LOG4CXX_STR("Use the <")+String(CONFIGURATION_TAG)+ | 1074 | | // LOG4CXX_STR("> element instead.")); | 1075 | 394 | } | 1076 | 69 | else | 1077 | 69 | { | 1078 | 69 | LogString msg(LOG4CXX_STR("Root element [")); | 1079 | 69 | utf8Decoder->decode(element->name, MAX_ATTRIBUTE_NAME_LEN, msg); | 1080 | 69 | msg += LOG4CXX_STR("] is not ["); | 1081 | 69 | utf8Decoder->decode(CONFIGURATION_TAG, MAX_ATTRIBUTE_NAME_LEN, msg); | 1082 | 69 | msg += LOG4CXX_STR("]"); | 1083 | 69 | LogLog::error(msg); | 1084 | 69 | return; | 1085 | 69 | } | 1086 | 463 | } | 1087 | | | 1088 | 394 | LogString debugAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_DEBUG_ATTR)); | 1089 | | | 1090 | | // if the log4j.dtd is not specified in the XML file, then the | 1091 | | // "debug" attribute is returned as the empty string. | 1092 | 394 | if (!debugAttrib.empty() && debugAttrib != LOG4CXX_STR("NULL")) | 1093 | 144 | { | 1094 | 144 | LogLog::setInternalDebugging(OptionConverter::toBoolean(debugAttrib, true)); | 1095 | 144 | } | 1096 | | | 1097 | 394 | LogString colorAttrib = subst(getAttribute(utf8Decoder, element, INTERNAL_COLOR_ATTR)); | 1098 | 394 | if (!colorAttrib.empty()) | 1099 | 24 | { | 1100 | 24 | LogLog::setColorEnabled(OptionConverter::toBoolean(colorAttrib, true)); | 1101 | 24 | } | 1102 | | | 1103 | 394 | LogString thresholdStr = subst(getAttribute(utf8Decoder, element, THRESHOLD_ATTR)); | 1104 | | | 1105 | 394 | if (!thresholdStr.empty() && thresholdStr != LOG4CXX_STR("NULL")) | 1106 | 161 | { | 1107 | 161 | m_priv->repository->setThreshold(OptionConverter::toLevel(thresholdStr, Level::getAll())); | 1108 | 161 | if (LogLog::isDebugEnabled()) | 1109 | 158 | { | 1110 | 158 | LogLog::debug(LOG4CXX_STR("Repository threshold =[") | 1111 | 158 | + m_priv->repository->getThreshold()->toString() | 1112 | 158 | + LOG4CXX_STR("]")); | 1113 | 158 | } | 1114 | 161 | } | 1115 | | | 1116 | 394 | LogString threadSignalValue = subst(getAttribute(utf8Decoder, element, THREAD_CONFIG_ATTR)); | 1117 | | | 1118 | 394 | if ( !threadSignalValue.empty() && threadSignalValue != LOG4CXX_STR("NULL") ) | 1119 | 51 | { | 1120 | 51 | if (LogLog::isDebugEnabled()) | 1121 | 50 | { | 1122 | 50 | LogLog::debug(LOG4CXX_STR("ThreadUtility configuration =[") + threadSignalValue + LOG4CXX_STR("]")); | 1123 | 50 | } | 1124 | 51 | if ( threadSignalValue == LOG4CXX_STR("NoConfiguration") ) | 1125 | 0 | { | 1126 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NoConfiguration ); | 1127 | 0 | } | 1128 | 51 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsOnly") ) | 1129 | 0 | { | 1130 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsOnly ); | 1131 | 0 | } | 1132 | 51 | else if ( threadSignalValue == LOG4CXX_STR("NameThreadOnly") ) | 1133 | 0 | { | 1134 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::NameThreadOnly ); | 1135 | 0 | } | 1136 | 51 | else if ( threadSignalValue == LOG4CXX_STR("BlockSignalsAndNameThread") ) | 1137 | 0 | { | 1138 | 0 | helpers::ThreadUtility::configure( ThreadConfigurationType::BlockSignalsAndNameThread ); | 1139 | 0 | } | 1140 | 51 | else | 1141 | 51 | { | 1142 | 51 | LogLog::warn(LOG4CXX_STR("threadConfiguration value [") + threadSignalValue + LOG4CXX_STR("]") + LOG4CXX_STR(" is not valid")); | 1143 | 51 | } | 1144 | 51 | } | 1145 | | | 1146 | 394 | apr_xml_elem* currentElement; | 1147 | | | 1148 | 394 | for (currentElement = element->first_child; | 1149 | 394 | currentElement; | 1150 | 394 | currentElement = currentElement->next) | 1151 | 0 | { | 1152 | 0 | std::string tagName(currentElement->name); | 1153 | |
| 1154 | 0 | if (tagName == CATEGORY_FACTORY_TAG) | 1155 | 0 | { | 1156 | 0 | parseLoggerFactory(p, utf8Decoder, currentElement); | 1157 | 0 | } | 1158 | 0 | } | 1159 | | | 1160 | 394 | for (currentElement = element->first_child; | 1161 | 394 | currentElement; | 1162 | 394 | currentElement = currentElement->next) | 1163 | 0 | { | 1164 | 0 | std::string tagName(currentElement->name); | 1165 | |
| 1166 | 0 | if (tagName == CATEGORY || tagName == LOGGER) | 1167 | 0 | { | 1168 | 0 | parseLogger(p, utf8Decoder, currentElement, doc, appenders); | 1169 | 0 | } | 1170 | 0 | else if (tagName == ROOT_TAG) | 1171 | 0 | { | 1172 | 0 | parseRoot(p, utf8Decoder, currentElement, doc, appenders); | 1173 | 0 | } | 1174 | 0 | } | 1175 | 394 | } |
|
1176 | | |
1177 | | LogString DOMConfigurator::subst(const LogString& value) |
1178 | 3.36k | { |
1179 | 3.36k | try |
1180 | 3.36k | { |
1181 | 3.36k | return OptionConverter::substVars(value, m_priv->props); |
1182 | 3.36k | } |
1183 | 3.36k | catch (IllegalArgumentException& e) |
1184 | 3.36k | { |
1185 | 214 | LogLog::warn(LOG4CXX_STR("Could not substitute variables using [") + value + LOG4CXX_STR("]"), e); |
1186 | 214 | return value; |
1187 | 214 | } |
1188 | 3.36k | } log4cxx::xml::DOMConfigurator::subst(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 1178 | 1.79k | { | 1179 | 1.79k | try | 1180 | 1.79k | { | 1181 | 1.79k | return OptionConverter::substVars(value, m_priv->props); | 1182 | 1.79k | } | 1183 | 1.79k | catch (IllegalArgumentException& e) | 1184 | 1.79k | { | 1185 | 108 | LogLog::warn(LOG4CXX_STR("Could not substitute variables using [") + value + LOG4CXX_STR("]"), e); | 1186 | 108 | return value; | 1187 | 108 | } | 1188 | 1.79k | } |
log4cxx::xml::DOMConfigurator::subst(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) Line | Count | Source | 1178 | 1.57k | { | 1179 | 1.57k | try | 1180 | 1.57k | { | 1181 | 1.57k | return OptionConverter::substVars(value, m_priv->props); | 1182 | 1.57k | } | 1183 | 1.57k | catch (IllegalArgumentException& e) | 1184 | 1.57k | { | 1185 | 106 | LogLog::warn(LOG4CXX_STR("Could not substitute variables using [") + value + LOG4CXX_STR("]"), e); | 1186 | 106 | return value; | 1187 | 106 | } | 1188 | 1.57k | } |
|
1189 | | |
1190 | | |
1191 | | LogString DOMConfigurator::getAttribute( |
1192 | | LOG4CXX_NS::helpers::CharsetDecoderPtr& utf8Decoder, |
1193 | | apr_xml_elem* element, |
1194 | | const std::string& attrName) |
1195 | 3.36k | { |
1196 | 3.36k | LogString attrValue; |
1197 | | |
1198 | 3.36k | for (apr_xml_attr* attr = element->attr; |
1199 | 7.51k | attr; |
1200 | 4.14k | attr = attr->next) |
1201 | 4.14k | { |
1202 | 4.14k | if (attrName == attr->name) |
1203 | 1.00k | { |
1204 | 1.00k | utf8Decoder->decode(attr->value, MAX_ATTRIBUTE_NAME_LEN, attrValue); |
1205 | 1.00k | } |
1206 | 4.14k | } |
1207 | | |
1208 | 3.36k | return attrValue; |
1209 | 3.36k | } |