|
When you have a huge number of cubes, it takes a lot of time to check all the transformer logfiles. This macro scans the c:\temp directory for files with a log extension. All the found log files are scanned and when a TR, Warning or Error text is found the line is copied to a c:\temp\README.txt file. Copy this code and paste it in CognosScript editor. Change the directory path where your transformer log files are located. Save the file and run the macro. '**************************************************************************************** ' Date: ' Name: CUBE_BUILD_NOTIFY ' Author: Administrator ' ' Description: This macro parses Transformer logfiles for user-defined text strings ' and write the error to c:\temp when the strings occur. ' '**************************************************************************************** Option Explicit Dim LogFileNo As Integer Dim FileNo As Integer Dim FileLine As String Dim AppPath As String Dim iniFile As String Dim LogPath As String Dim TransformerLogFile As String Dim ScriptLogFile As String Dim CurrentLogFile As String Dim CRLF As String ' Location of the logfile to be scanned. const REPORTDIRECTORYPATH = "C:\Temp" Declare Sub Log_Info(Msg_In As String) ' ----------------------------------------------------------------------------------------- Sub Main () Dim FileName As String Dim ReportDirectory As String On Error Goto ErrorTrap CRLF = Chr$(13) & Chr$(10) LogPath = "C:\TEMP" 'setup connection to output logfile Cube_Build_Notify_Script.log ScriptLogFile = LogPath & "\README.txt" LogFileNo = Freefile() Open ScriptLogFile for Output As LogFileNo Print #LogFileNo, "CUBE_BUILD_NOTIFY Script " & Date() & " " & Time() & CRLF Print #LogFileNo, "Transformer Log File: " & ScriptLogFile & CRLF FileNo = FreeFile() ReportDirectory = REPORTDIRECTORYPATH & "\*.log" 'Set directory to scan FileName= Dir (ReportDirectory) Do While FileName<>"" CurrentLogFile = REPORTDIRECTORYPATH & "\" & FileName Open CurrentLogFile For Input As FileNo ' open Transformer log file Print #LogFileNo, "<<< " & CurrentLogFile & " gestart... >>>" Do While Not Eof(FileNo) Line Input #FileNo, FileLine ' read each line in log file If InStr(1, FileLine, "Error:", 1) > 0 Then call Log_Info(FileLine) End If If InStr(1, FileLine, "Warning:", 1) > 0 Then call Log_Info(FileLine) End If If InStr(1, FileLine, "(TR", 1) > 0 Then call Log_Info(FileLine) End If Loop Print #LogFileNo, "<<< " & CurrentLogFile & " afgerond >>>" Close FileNo ' close Transformer log file FileName=Dir Loop call Log_Info("End CUBE_BUILD_NOTIFY Script ") Exit Sub errorTrap: Call Log_Info("Error " & Str(Err) & ": " & Error$(Err)) Close #LogFileNo End Sub 'main '-------------------------------------------------------------------------------------------- Sub Log_Info(Msg_In as String) Print #LogFileNo, Date() & "-" & Time() & ": " & Msg_In End Sub '--------------------------------------------------------------------------------------------
|
Comments