'function to get recent log file
Public Function fnRecentLogFile(strLogpath)
Set recentLogFile = Nothing
For Each file in fsoLogFile.GetFolder(strLogpath).Files
If (recentLogFile is Nothing) Then
Set recentLogFile = file
ElseIf (file.DateLastModified > recentLogFile.DateLastModified) Then
Set recentLogFile = file
End If
Next
End Function
'function to verify log messages present in file or not
Function fnVerifyLogFile(strLogFilePath,strLogFileMsg)
Dim Flag
Call fnRecentLogFile(strLogFilePath)
Set objFile = fsoLogFile.OpenTextFile(recentLogFile)
line_num=0
Dim bMatchFlag
bMatchFlag=False
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
line_num = line_num+1
If InStr(strLine,strLogFileMsg)>0 Then
'msgbox strLine
bMatchFlag=True
Exit Do
else
bMatchFlag=False
End If
Loop
If bMatchFlag=True Then
Call fnDoneResult("Log Message Present",strLogFileMsg & "Log Message Present in LOG File.")
Flag=True
else
Call fnFailResult("Log Message not present",strLogFileMsg & "Log Message not present in LOG File.")
Flag=False
End If
fnVerifyLogFile=Flag
End Function
Public Function fnRecentLogFile(strLogpath)
Set recentLogFile = Nothing
For Each file in fsoLogFile.GetFolder(strLogpath).Files
If (recentLogFile is Nothing) Then
Set recentLogFile = file
ElseIf (file.DateLastModified > recentLogFile.DateLastModified) Then
Set recentLogFile = file
End If
Next
End Function
'function to verify log messages present in file or not
Function fnVerifyLogFile(strLogFilePath,strLogFileMsg)
Dim Flag
Call fnRecentLogFile(strLogFilePath)
Set objFile = fsoLogFile.OpenTextFile(recentLogFile)
line_num=0
Dim bMatchFlag
bMatchFlag=False
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
line_num = line_num+1
If InStr(strLine,strLogFileMsg)>0 Then
'msgbox strLine
bMatchFlag=True
Exit Do
else
bMatchFlag=False
End If
Loop
If bMatchFlag=True Then
Call fnDoneResult("Log Message Present",strLogFileMsg & "Log Message Present in LOG File.")
Flag=True
else
Call fnFailResult("Log Message not present",strLogFileMsg & "Log Message not present in LOG File.")
Flag=False
End If
fnVerifyLogFile=Flag
End Function
No comments:
Post a Comment