Support --enable-debug-logs=no option of configure script (#2)

* Support --enable-debug-logs=no option of configure script

* Undo unintended white space changes

* Undo more unintended white space changes

* Address review comments - thanks Mirko

* Address more review comments - thanks Mirko
This commit is contained in:
michaelgranzow-avi
2017-08-03 19:50:43 +02:00
committed by Felipe Zimmerle
parent 1d3c4c670d
commit 3a048ee2db
22 changed files with 305 additions and 4 deletions

View File

@@ -99,8 +99,10 @@ bool Pm::evaluate(Transaction *transaction, Rule *rule,
if (capture && transaction && rc) {
transaction->m_collections.storeOrUpdateFirst("TX", "0",
std::string(match));
#ifndef NO_LOGS
transaction->debug(7, "Added pm match TX.0: " + \
std::string(match));
#endif
}
return rc > 0;

View File

@@ -45,8 +45,10 @@ bool Rx::evaluate(Transaction *transaction, Rule *rule,
for (const SMatch& a : matches) {
transaction->m_collections.storeOrUpdateFirst("TX",
std::to_string(i), a.match);
#ifndef NO_LOGS
transaction->debug(7, "Added regex subexpression TX." +
std::to_string(i) + ": " + a.match);
#endif
transaction->m_matched.push_back(a.match);
i++;
}

View File

@@ -50,19 +50,25 @@ bool ValidateDTD::evaluate(Transaction *t, const std::string &str) {
if (m_dtd == NULL) {
std::string err = std::string("XML: Failed to load DTD: ") \
+ m_resource;
#ifndef NO_LOGS
t->debug(4, err);
#endif
return true;
}
if (t->m_xml->m_data.doc == NULL) {
#ifndef NO_LOGS
t->debug(4, "XML document tree could not "\
"be found for DTD validation.");
#endif
return true;
}
if (t->m_xml->m_data.well_formed != 1) {
#ifndef NO_LOGS
t->debug(4, "XML: DTD validation failed because " \
"content is not well formed.");
#endif
return true;
}
@@ -78,7 +84,9 @@ bool ValidateDTD::evaluate(Transaction *t, const std::string &str) {
cvp = xmlNewValidCtxt();
if (cvp == NULL) {
#ifndef NO_LOGS
t->debug(4, "XML: Failed to create a validation context.");
#endif
return true;
}
@@ -88,13 +96,17 @@ bool ValidateDTD::evaluate(Transaction *t, const std::string &str) {
cvp->userData = t;
if (!xmlValidateDtd(cvp, t->m_xml->m_data.doc, m_dtd)) {
#ifndef NO_LOGS
t->debug(4, "XML: DTD validation failed.");
#endif
xmlFreeValidCtxt(cvp);
return true;
}
#ifndef NO_LOGS
t->debug(4, std::string("XML: Successfully validated " \
"payload against DTD: ") + m_resource);
#endif
xmlFreeValidCtxt(cvp);

View File

@@ -62,7 +62,9 @@ class ValidateDTD : public Operator {
if (len > 0) {
s = "XML Error: " + std::string(buf);
}
#ifndef NO_LOGS
t->debug(4, s);
#endif
}
@@ -79,7 +81,9 @@ class ValidateDTD : public Operator {
if (len > 0) {
s = "XML Warning: " + std::string(buf);
}
#ifndef NO_LOGS
t->debug(4, s);
#endif
}

View File

@@ -50,7 +50,9 @@ bool ValidateSchema::evaluate(Transaction *t,
if (m_err.empty() == false) {
err << m_err;
}
#ifndef NO_LOGS
t->debug(4, err.str());
#endif
return true;
}
@@ -73,7 +75,9 @@ bool ValidateSchema::evaluate(Transaction *t,
if (m_err.empty() == false) {
err << " " << m_err;
}
#ifndef NO_LOGS
t->debug(4, err.str());
#endif
xmlSchemaFreeParserCtxt(m_parserCtx);
return true;
}
@@ -84,7 +88,9 @@ bool ValidateSchema::evaluate(Transaction *t,
if (m_err.empty() == false) {
err << " " << m_err;
}
#ifndef NO_LOGS
t->debug(4, err.str());
#endif
return true;
}
@@ -94,36 +100,46 @@ bool ValidateSchema::evaluate(Transaction *t,
(xmlSchemaValidityWarningFunc)warn_runtime, t);
if (t->m_xml->m_data.doc == NULL) {
#ifndef NO_LOGS
t->debug(4, "XML document tree could not be found for " \
"schema validation.");
#endif
return true;
}
if (t->m_xml->m_data.well_formed != 1) {
#ifndef NO_LOGS
t->debug(4, "XML: Schema validation failed because " \
"content is not well formed.");
#endif
return true;
}
/* Make sure there were no other generic processing errors */
/*
if (msr->msc_reqbody_error) {
#ifndef NO_LOGS
t->debug(4, "XML: Schema validation could not proceed due to previous"
" processing errors.");
#endif
return true;
}
*/
rc = xmlSchemaValidateDoc(m_validCtx, t->m_xml->m_data.doc);
if (rc != 0) {
t->debug(4, "XML: Schema validation failed.");
#ifndef NO_LOGS
t->debug(4, "XML: Schema validation failed.");
#endif
xmlSchemaFree(m_schema);
xmlSchemaFreeParserCtxt(m_parserCtx);
return true; /* No match. */
}
#ifndef NO_LOGS
t->debug(4, "XML: Successfully validated payload against " \
"Schema: " + m_resource);
#endif
return false;
}

View File

@@ -103,7 +103,9 @@ class ValidateSchema : public Operator {
if (len > 0) {
s = "XML Error: " + std::string(buf);
}
#ifndef NO_LOGS
t->debug(4, s);
#endif
}
@@ -120,7 +122,9 @@ class ValidateSchema : public Operator {
if (len > 0) {
s = "XML Warning: " + std::string(buf);
}
#ifndef NO_LOGS
t->debug(4, s);
#endif
}
static void null_error(void *ctx, const char *msg, ...) {