导入Pywinauto会导致调试消息出现两次



我有一个旧的python脚本,它使用刚刚通过添加pywinauto进行更新的记录。

任何日志线都按照日志文件的预期编写,但是一旦导入了Pywinauto,我将获得2个写入控制台的行的副本。

评论导入的Pywinauto行解决了问题(但不是真正的解决方案,因为我需要使用库)

import logging
import pywinauto
# Set up a script_logger.
script_logger = logging.getLogger('test')
script_logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
script_logger.addHandler(ch)
logFilename = "debug.log"
fh = logging.FileHandler(logFilename)
fh.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
script_logger.addHandler(fh)
script_logger.debug("Hello world")

典型输出(第一行预期,第二行)

2016-12-15 17:43:09,056 - test - DEBUG - Hello world
2016-12-15 17:43:09,056 DEBUG: Hello world

我可以看到第二行是在

中创建的

lib site-packages pywinauto actionlogger.py

有什么想法吗?

谢谢

现在应该在主分支中固定。您可以使用pip install https://github.com/pywinauto/pywinauto/archive/master.zip尝试一下吗?

最新更新