C++ 禁用libxml2和xmlsec中的调试输出

C++ 禁用libxml2和xmlsec中的调试输出,c++,c,debugging,libxml2,xmlsec,C++,C,Debugging,Libxml2,Xmlsec,在我的软件中,我使用和操作(显然)XML数据结构。我主要使用XSD模式验证,到目前为止,它运行良好 当客户端输入的数据结构与XSD模式不匹配时,libxml2(或xmlsec)会向控制台输出一些调试字符串 以下是一个例子: Entity: line 1: parser error : Start tag expected, '<' not found DUMMY<?xml ^ Entity:line 1:parser error:Start tag应为“我将研究和函数,它们似乎是正

在我的软件中,我使用和操作(显然)XML数据结构。我主要使用XSD模式验证,到目前为止,它运行良好

当客户端输入的数据结构与XSD模式不匹配时,libxml2(或xmlsec)会向控制台输出一些调试字符串

以下是一个例子:

Entity: line 1: parser error : Start tag expected, '<' not found
DUMMY<?xml
^

Entity:line 1:parser error:Start tag应为“我将研究
函数,它们似乎是正确的。文档是。。不过是稀疏的

是一些似乎使用这些函数来禁用错误消息的Python代码,相关行如下所示:

# dummy function: no debug output at all
cdef void _nullGenericErrorFunc(void* ctxt, char* msg, ...) nogil:
    pass

# setup for global log:

cdef void _initThreadLogging():
    # disable generic error lines from libxml2
    xmlerror.xmlThrDefSetGenericErrorFunc(NULL, _nullGenericErrorFunc)
    xmlerror.xmlSetGenericErrorFunc(NULL, _nullGenericErrorFunc)

我在为一些C代码寻找相同的解决方案:

static void __xmlGenericErrorFunc (void *ctx, const char *msg, ...) { }
xmlSetGenericErrorFunc(nil, __xmlGenericErrorFunc);
xmlThrDefSetGenericErrorFunc(nil, __xmlGenericErrorFunc);

+1:谢谢!当然,文档真的很糟糕。今天晚上我会检查这是否有效。我会通知你的。@ereOn:太棒了。我添加了一个更通用的函数,以及我发现应该对您有所帮助的示例代码。通过在libxml的站点上搜索,似乎还可以找到大量的邮件列表帖子。