Welcome to the new CogKnowHow.com!


If you have trouble logging in, reset your password via the login window
by clicking the 'Forgot Password' link.

Transformer log file checker


#1

Nice macro, some years ago

'****************************************************************************************
' Date: 01-08-2005
' Name: CUBE_BUILD_NOTIFY
' Author: Martijn Christenhusz
'
' Description: This macro parses Transformer logfiles for user-defined text strings
' and write the error to d:\transformer_logs 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  & "\LEESMIJ.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

'--------------------------------------------------------------------------------------------