Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging 浏览不同文件夹中的不同文件以创建日志摘要报告VBscript_Logging_Vbscript_Qtp - Fatal编程技术网

Logging 浏览不同文件夹中的不同文件以创建日志摘要报告VBscript

Logging 浏览不同文件夹中的不同文件以创建日志摘要报告VBscript,logging,vbscript,qtp,Logging,Vbscript,Qtp,由于我有一段时间没有使用VBscript编写代码,我需要您的帮助来创建日志摘要报告文件 我有一个名为“Logs”的文件夹,在这个文件夹中,我将有不同的子文件夹(按系统时间命名),在每个文件夹中,我将有许多日志文本文件,其中显示了一组测试的测试摘要结果 我想编写一个脚本,浏览每个文件,计算测试次数,获取失败/通过测试的次数,并创建一个文本文件来显示这些详细信息: 以下是我用于在每个文件中创建摘要报告的代码: Public Sub PrintTestVectors fprint vbNew

由于我有一段时间没有使用VBscript编写代码,我需要您的帮助来创建日志摘要报告文件

我有一个名为“Logs”的文件夹,在这个文件夹中,我将有不同的子文件夹(按系统时间命名),在每个文件夹中,我将有许多日志文本文件,其中显示了一组测试的测试摘要结果

我想编写一个脚本,浏览每个文件,计算测试次数,获取失败/通过测试的次数,并创建一个文本文件来显示这些详细信息:

以下是我用于在每个文件中创建摘要报告的代码:

 Public Sub PrintTestVectors
    fprint vbNewLine & "===================="
    fprint             "SUMMARY OF RESULTS:"
    fprint             "===================="
    sVector = ""

    While oTestVectors.Count <> 0
        fprint "TEST [" & oTestVectors.Count & "] STATUS:" & oTestResults.Pop() & "        
        TRACE:" & oTestVectors.Pop()
    Wend
    fprint sVector 
    fprint vbNewLine

    End Sub
公共子PrintTestVectors
fprint vbNewLine&“=====================================================================”
fprint“结果摘要:”
fprint“========================================”
sVector=“”
而不是向量。计数0
fprint“TEST[”&oTestVectors.Count&“]状态:&oTestResults.Pop()&”
跟踪:“&oTestVectors.Pop()
温德
fprint sVector
fprint vbNewLine
端接头

谢谢

显示要处理的某个日志文件的实际示例会更有帮助。感谢您的回答,我应该如何/在哪里调用此函数?调用PrintLog(“c:\mylog.txt”,“这是我的日志消息”)
can be done using 

Public Function PrintLog(logfile,strLogMessage)
Const fsoForAppend = 8

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

if Not objFSO.FileExists(logfile) Then 
objFSO.CreateTextFile(objFSO,false)
End if

'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile(logfile, fsoForAppend)

'Display the contents of the text file
objTextStream.WriteLine strLogMessage

'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
End Function