2
我有一个旧的python脚本,它使用了我刚刚通过添加pywinauto进行更新的日志记录。导入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
我可以看到第二行内
库\站点包\ pywinauto \ actionlogger创建.py
有什么想法?
谢谢
这可能是pywinauto中的一个错误。感谢您报告这一点。不幸的是,在新年之后会看到这个。 –
任何想法,当这可能会看?我应该在pywinauto上打一张票吗? – KermitG
刚从假期旅行回来。将尽快看看。导入pywinauto时,comtypes警告也存在另一个问题。 –