在libxml2和xmlsec禁用调试输出 [英] Disable debug output in libxml2 and xmlsec
问题描述
在我的软件,我用的libxml2 并的 xmlsec 操纵(明显)的XML数据结构。我主要使用XSD架构验证,到目前为止,它工作得很好。
In my software, I use libxml2 and xmlsec to manipulate (obviously) XML data structures. I mainly use XSD schema validation and so far, it works well.
在客户端的数据结构输入不匹配的XSD架构,libxml2的(或xmlsec)输出一些调试字符串到控制台。
When the data structure input by the client doesn't match the XSD schema, libxml2 (or xmlsec) output some debug strings to the console.
下面是一个例子:
Entity: line 1: parser error : Start tag expected, '<' not found
DUMMY<?xml
^
虽然这些字符串的有用的进行调试,我不希望他们出现,polute控制台输出在发布的软件。到目前为止,我无法找到这样做的正式途径。
While those strings are useful for debugging purposes, I don't want them to appear and polute the console output in the released software. So far, I couldn't find an official way of doing this.
你知道如何用晚餐preSS调试输出或(甚至更好)将其重定向到一个自定义函数?
Do you know how to suppress the debug output or (even better) to redirect it to a custom function ?
非常感谢。
推荐答案
我将调查的 xmlSetGenericErrorFunc()
和的 xmlThrDefSetGenericErrorFunc()
的功能,他们似乎对的。该文档是..稀疏,虽然。
I would investigate the xmlSetGenericErrorFunc()
and xmlThrDefSetGenericErrorFunc()
functions, they seem right. The documentation is .. sparse, though.
这里是一些Python code,它似乎使用这些功能禁用错误消息,相关线路是这样的:
Here is some Python code that seems to use these functions to disable error messages, the relevant lines look like this:
# 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)
这篇关于在libxml2和xmlsec禁用调试输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!