Python日志调试级别不会消失

2024-03-28 11:48:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试禁用Python2.6.6中的调试日志记录,它在运行某些命令时似乎会触发。。。我尝试了似乎所有的解决方案,但仍然得到了不想要的结果

我甚至包括:

logging.disable(logging.CRITICAL)

同样的结果

当我通过cmd提示符运行相同的命令(test.cmd)时,我得到了预期的输出。当我通过python脚本运行同一命令时,使用以下代码:

p = Popen([test, "report"], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = p.stdout.read()
print output

我得到了以下信息(而且还在继续):

07/06/18 08:13:16 DEBUG : Enter:  HTTPSender::invoke
Enter:  HTTPSender::invoke
07/06/18 08:13:16 DEBUG : XML sent:
XML sent:
07/06/18 08:13:16 DEBUG : ---------------------------------------------------
---------------------------------------------------
07/06/18 08:13:16 DEBUG : POST /awstestservice/soap HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "awstestReport"
Content-Length: 327

有什么想法吗


Tags: debugtest命令cmdoutputloggingstdoutxml
1条回答
网友
1楼 · 发布于 2024-03-28 11:48:29

我最后写了以下解决方法:

#Verify the report was created
output = p.stdout.read()
status = output.rfind('Report created')

#Update Report Status
if (status!=-1):
 print ("Report Created")
else:
print ("Error")

不知道这是否有帮助,但它解决了我的问题

相关问题 更多 >