Changes debuglogs schema to avoid unecessary str allocation

This commit is contained in:
Felipe Zimmerle
2018-10-19 16:56:33 -03:00
parent 23e0d35d2d
commit ef7f65db90
57 changed files with 1100 additions and 1374 deletions

View File

@@ -82,42 +82,32 @@ void XML::evaluate(Transaction *t,
xpathExpr = (const xmlChar*)param.c_str();
xpathCtx = xmlXPathNewContext(t->m_xml->m_data.doc);
if (xpathCtx == NULL) {
#ifndef NO_LOGS
t->debug(1, "XML: Unable to create new XPath context. : ");
#endif
ms_dbg_a(t, 1, "XML: Unable to create new XPath context. : ");
return;
}
if (rule == NULL) {
#ifndef NO_LOGS
t->debug(2, "XML: Can't look for xmlns, internal error.");
#endif
ms_dbg_a(t, 2, "XML: Can't look for xmlns, internal error.");
} else {
std::vector<actions::Action *> acts = rule->getActionsByName("xmlns", t);
for (auto &x : acts) {
actions::XmlNS *z = (actions::XmlNS *)x;
if (xmlXPathRegisterNs(xpathCtx, (const xmlChar*)z->m_scope.c_str(),
(const xmlChar*)z->m_href.c_str()) != 0) {
#ifndef NO_LOGS
t->debug(1, "Failed to register XML namespace href \"" + \
ms_dbg_a(t, 1, "Failed to register XML namespace href \"" + \
z->m_href + "\" prefix \"" + z->m_scope + "\".");
#endif
return;
}
#ifndef NO_LOGS
t->debug(4, "Registered XML namespace href \"" + z->m_href + \
ms_dbg_a(t, 4, "Registered XML namespace href \"" + z->m_href + \
"\" prefix \"" + z->m_scope + "\"");
#endif
}
}
/* Initialise XPath expression. */
xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
if (xpathObj == NULL) {
#ifndef NO_LOGS
t->debug(1, "XML: Unable to evaluate xpath expression.");
#endif
ms_dbg_a(t, 1, "XML: Unable to evaluate xpath expression.");
xmlXPathFreeContext(xpathCtx);
return;
}