从导入的python文件中获取日志记录信息。
我正在构建一个基于python的测试套件。测试是使用__import函数调用的,我希望在我的测试应用程序中捕获日志记录消息(在测试中)。日志消息是使用python日志记录模块生成的。我该怎么做呢?例如在psuedo代码中:
for test in testList:
# do something
# Import Test
testid = __import__(test)
testOut = testid.run
我正在运行python脚本,我想记录python程序的每个步骤。
例如,假设我有一个程序
def main()
if do:
do the work
if yes:
do the work
for list os.listdir(dir):
sys.system("python " + dirOfPython + " " + dirOflists)
我想记录我的程序在哪里..。以及他们目前正在做的事情。
在我的日志里我想要像
Inside of main()