Page 1 of 2

logviewer

Posted: Thu Jun 10, 2004 2:56 pm
by blueznl

Posted: Thu Jun 10, 2004 3:16 pm
by blueznl
on tommeh's special request up to 999999 lines can be read now...

Posted: Thu Jun 10, 2004 3:30 pm
by fweil
Blueznl,

Does not read 'entry' data on some files ...

It seems that you do not accept > 64KB files to get 'entry' data. Maybe I am wrong.

Posted: Thu Jun 10, 2004 3:50 pm
by blueznl
updated

Posted: Thu Jun 10, 2004 3:56 pm
by fweil
blueznl you do fast !

I love it ...

Posted: Thu Jun 10, 2004 4:02 pm
by blueznl
tommeh mentioned it in the chat channel, it was a limit in there for testing purposes

the way things go when it starts out as a self educational project :-)

Posted: Thu Jun 10, 2004 4:04 pm
by fweil
BTW have you seen my event log viewer source ? I guess so ...

Posted: Thu Jun 10, 2004 4:11 pm
by blueznl
nope

but i might have a look at it soon :-)

this program was mostly written to monitor continously changing log files, such as lists of callers, debugging output etc.

Posted: Thu Jun 10, 2004 4:17 pm
by fweil

Code: Select all

#EVENTLOG_TYPE_SYSTEM = "System" 
#EVENTLOG_TYPE_APPLICATION = "Application" 
#EVENTLOG_TYPE_SECURITY = "Security"
#EVENTLOG_SEQUENTIAL_READ = $1
#EVENTLOG_SEEK_READ = $2
#EVENTLOG_FORWARDS_READ = $4 ; If you want to use FORWARDS you will have to use SEEK_READ also
#EVENTLOG_BACKWARDS_READ = $8

#EVENTLOG_ERROR_TYPE = $1; Error event
#EVENTLOG_WARNING_TYPE = $2; Warning event
#EVENTLOG_INFORMATION_TYPE = $4; Information event
#EVENTLOG_AUDIT_SUCCESS = $8; Success Audit event
#EVENTLOG_AUDIT_FAILURE = $10; Failure Audit event

Enumeration  
  #Window_Main
  #Gadget_Panel
  #Gadget_ListIcon_Application
  #Gadget_ListIcon_System
  #Gadget_ListIcon_Security
  #StatusBar
EndEnumeration

Global TimeBias.l

Procedure ParseEvent(*Buffer, RecordNumber.l, BytesRead.l, EventLogType.s)
UTCtime.SYSTEMTIME
LocalTime.SYSTEMTIME
EventRecord.EVENTLOGRECORD
  StrucLen = SizeOf(EVENTLOGRECORD)
  BytePointer = 0
  While BytePointer < BytesRead ;- EvtRecLen
    CopyMemory(*Buffer + BytePointer, EventRecord, StrucLen)
    EvtRecLen = EventRecord\Length
    a$ = PeekS(*Buffer + BytePointer + StrucLen)
    l = Len(a$) + 1
    b$= PeekS(*Buffer + BytePointer + StrucLen + l)
    sEventType.s = ""
    If EventRecord\EventType & #EVENTLOG_ERROR_TYPE
        sEventType = sEventType + "Error event "
    EndIf
    If EventRecord\EventType & #EVENTLOG_WARNING_TYPE
        sEventType = sEventType + "Warning event "
    EndIf
    If EventRecord\EventType & #EVENTLOG_INFORMATION_TYPE
        sEventType = sEventType + "Information event "
    EndIf
    If EventRecord\EventType & #EVENTLOG_AUDIT_SUCCESS
        sEventType = sEventType + "Success Audit event "
    EndIf
    If EventRecord\EventType & #EVENTLOG_AUDIT_FAILURE
        sEventType = sEventType + "Failure Audit event "
    EndIf
    TimeGenerated.s = FormatDate("%YYYY/%mm/%dd %hh:%ii:%ss ", EventRecord\TimeGenerated - TimeBias)
    TimeWritten.s = FormatDate("%YYYY/%mm/%dd %hh:%ii:%ss ", EventRecord\TimeWritten - TimeBias)
    If EventRecord\NumStrings > 0
        c$ = ""
        l = 0
        For r = 1 To EventRecord\NumStrings
          c$= PeekS(*Buffer + BytePointer + l + EventRecord\StringOffset)
          Result.s = b$ + Chr(10) + a$ + Chr(10) + sEventType + Chr(10) + TimeGenerated + Chr(10) + TimeWritten + Chr(10) + c$
          l + Len(c$) + 1
        Next r
      Else
        Result.s = b$ + Chr(10) + a$ + Chr(10) + sEventType + Chr(10) + TimeGenerated + Chr(10) + TimeWritten + Chr(10) + ""
    EndIf
    Select EventLogType
      Case #EVENTLOG_TYPE_SYSTEM
        AddGadgetItem(#Gadget_ListIcon_System, -1, Result)
      Case #EVENTLOG_TYPE_APPLICATION
        AddGadgetItem(#Gadget_ListIcon_Application, -1, Result)
      Case #EVENTLOG_TYPE_SECURITY
        AddGadgetItem(#Gadget_ListIcon_Security, -1, Result)
    EndSelect
    While WindowEvent()
    Wend
    BytePointer + EvtRecLen
  Wend
EndProcedure

Procedure ReadEvents(ServerName,EventLogType.s)
  EventLogReadFlags = #EVENTLOG_SEQUENTIAL_READ | #EVENTLOG_FORWARDS_READ
  EventLogHandle = OpenEventLog_(Servername, EventLogType)
  BufferLength = 65536
  *Buffer = AllocateMemory(BufferLength)
  If EventLogHandle
      EventLogNumberOfRecords=0
      If GetNumberOfEventLogRecords_(EventLogHandle, @EventLogNumberOfRecords)
          rBytesRead=0
          rBytesNeeded=0
          Debug "EventLogNumberOfRecords = " + Str(EventLogNumberOfRecords)
          RecordNumber = 0
          While RecordNumber <= EventLogNumberOfRecords
            If ReadEventLog_(EventLogHandle, #EVENTLOG_SEQUENTIAL_READ | #EVENTLOG_BACKWARDS_READ, 0, *Buffer, BufferLength, @BytesRead, @BytesNeeded)
                ParseEvent(*Buffer, RecordNumber, BytesRead, EventLogType)
            EndIf
            RecordNumber + 1
          Wend
          CloseEventLog_(EventLogHandle)
          Result = 1
        Else
          Result = 0
      EndIf
    Else
      Result = 0
  EndIf
  FreeMemory(*Buffer)
  ProcedureReturn 0
EndProcedure

Procedure MyWindowCallBack(WindowID.l, Message.l, wParam.l, lParam.l)
  Result.l = #PB_ProcessPureBasicEvents
  Select Message
    Case #WM_PAINT
    Case #PB_EventRepaint
    Case #PB_EventMoveWindow
    Default
  EndSelect
  ProcedureReturn Result  
EndProcedure

;
; Main starts here
;
  GetSystemTime_(SystemTime.SYSTEMTIME)
  GetLocalTime_(LocalTime.SYSTEMTIME)
  TimeBias = Date(SystemTime\wYear, SystemTime\wMonth, SystemTime\wDay, SystemTime\wHour, SystemTime\wMinute, SystemTime\wSecond) - Date(LocalTime\wYear, LocalTime\wMonth, LocalTime\wDay, LocalTime\wHour, LocalTime\wMinute, LocalTime\wSecond)
  Quit = #FALSE
  WindowXSize = 320
  WindowYSize = 240
  If OpenWindow(#Window_Main, 0, 0, WindowXSize, WindowYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered, "MyWindow")
      AddKeyboardShortcut(#Window_Main, #PB_Shortcut_Escape, #PB_Shortcut_Escape)
      If CreateGadgetList(WindowID())
          PanelGadget(#Gadget_Panel, 10, 10, WindowXSize - 20, WindowYSize - 30)
            AddGadgetItem(#Gadget_Panel, -1, "Applications")
              ListIconGadget(#Gadget_ListIcon_Application, 10, 10, WindowXSize - 30, WindowYSize - 60, "Computer", 120)
            AddGadgetItem(#Gadget_Panel, -1, "System")
              ListIconGadget(#Gadget_ListIcon_System, 10, 10, WindowXSize - 30, WindowYSize - 60, "Computer", 120)
            AddGadgetItem(#Gadget_Panel, -1, "Security")
              ListIconGadget(#Gadget_ListIcon_Security, 10, 10, WindowXSize - 30, WindowYSize - 60, "Computer", 120)
            For i = #Gadget_ListIcon_Application To #Gadget_ListIcon_Security
              AddGadgetColumn(i, 1, "Source", 120)
              AddGadgetColumn(i, 2, "Type", 120)
              AddGadgetColumn(i, 3, "Generated", 120)
              AddGadgetColumn(i, 4, "Written", 120)
              AddGadgetColumn(i, 5, "Description", 120)
            Next
          CloseGadgetList()
      EndIf
      If CreateStatusBar(#StatusBar, WindowID())
          StatusBarText(#StatusBar, 0, "Loading events ...")
      EndIf
      SetWindowCallback(@MyWindowCallBack())
      ReadEvents(0, #EVENTLOG_TYPE_APPLICATION)
      ReadEvents(0, #EVENTLOG_TYPE_SYSTEM)
      ReadEvents(0, #EVENTLOG_TYPE_SECURITY)
      StatusBarText(#StatusBar, 0, Str(CountGadgetItems(#Gadget_ListIcon_Application)) + " items")
      Repeat
        Wevent = WaitWindowEvent()
        Select WEvent
          Case #PB_Event_CloseWindow
            Quit = #TRUE
          Case #PB_Event_Menu
            Select EventMenuID()
              Case #PB_Shortcut_Escape
                Quit = #TRUE
            EndSelect
          Case #PB_EventGadget
            Select EventGadgetID()
              Case #Gadget_Panel
                StatusBarText(#StatusBar, 0, Str(CountGadgetItems(#Gadget_ListIcon_Application)) + " items")
            EndSelect
          Case #WM_SIZE
            WindowXSize = WindowWidth()
            WindowYSize = WindowHeight()
            ResizeGadget(#Gadget_Panel, 10, 10, WindowXSize - 20, WindowYSize - 30)
            ResizeGadget(#Gadget_ListIcon_Application, 10, 10, WindowXSize - 30, WindowYSize - 60)
            ResizeGadget(#Gadget_ListIcon_System, 10, 10, WindowXSize - 30, WindowYSize - 60)
            ResizeGadget(#Gadget_ListIcon_Security, 10, 10, WindowXSize - 30, WindowYSize - 60)
        EndSelect
      Until Quit
  EndIf
  TerminateProcess_(GetCurrentProcess_(), 0)
End

Posted: Sat Jun 12, 2004 1:41 pm
by blueznl
updated

people with multi screen setups, and with a quick launch bar in strange :-) places, please test this with the command line parameter /full

logviewer /help /full file1.log file2.log

same url

http://www.wackoware.com/logviewer.exe

Posted: Sat Jun 12, 2004 3:02 pm
by fweil
blueznl,

Works fine here

Posted: Sat Jun 12, 2004 4:33 pm
by blueznl
minor update handling mulitple monitors

Posted: Mon Jun 14, 2004 1:05 am
by blueznl
wanna have fun testing your mouse buttons?

try logviewer 0.18x... and use on the commandline:

logviewer /info /full /drill:100 c:\*.htm c:\*.log c:\*.txt

have fun :-)

Posted: Mon Jun 14, 2004 5:12 pm
by blueznl
okay... mostly done, still some things left, but it's getting there...

logviewer 0.20b

http://www.wackoware.com/logviewer.exe

try on the commandline:

logviewer /drill:10 c:\*.htm /x:0 /y:0

large parts of logviewer are using procedures from the x_lib, the source of those routines you can find as part of the survival guide zip file

http://www.xs4all.nl/~bluez/datatalk/pb ... _guide.zip

Posted: Sun Jun 20, 2004 12:04 am
by blueznl
logviewer updated, it's getting there :-)

- system wide closing of viewers
- status leds
- some rewrite inside to handle eventual expansions
- few bugfixes

http://www.wackoware.com/logviewer.exe

not skinned yet... hey polyvector! hint :-)