在libxml2和xmlsec中禁用调试输出 [英] Disable debug output in libxml2 and xmlsec

查看:177
本文介绍了在libxml2和xmlsec中禁用调试输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的软件中,我使用 libxml2 xmlsec 来操纵(显然)XML数据结构。

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
^

这些字符串对于调试是非常有用的,我不希望它们在已发布的软件中显示和调制控制台输出<强>。到目前为止,我找不到一个正式的方式这样做。

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.

你知道如何抑制调试输出或(甚至更好)重定向到一个自定义

Do you know how to suppress the debug output or (even better) to redirect it to a custom function ?

非常感谢。

推荐答案

code> xmlSetGenericErrorFunc() xmlThrDefSetGenericErrorFunc() 函数,他们似乎是对的。文档是...稀疏。

I would investigate the xmlSetGenericErrorFunc() and xmlThrDefSetGenericErrorFunc() functions, they seem right. The documentation is .. sparse, though.

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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆