2021-03-29 08:36:45 +02:00
|
|
|
; logmonitor.pb
|
2021-03-22 00:39:55 +01:00
|
|
|
; ------------------------------------------------------------
|
2021-03-29 08:36:45 +02:00
|
|
|
; tool to monitor a logfile ...
|
2021-03-22 00:39:55 +01:00
|
|
|
; LICENSE : GPL
|
|
|
|
; AUTHOR : Michael H.G. Schmidt
|
|
|
|
; EMAIL : michael@schmidt2.de
|
2021-03-30 21:21:53 +02:00
|
|
|
; DATE : 20210330
|
2021-03-22 00:39:55 +01:00
|
|
|
; ------------------------------------------------------------
|
|
|
|
;
|
|
|
|
|
2021-03-29 08:36:45 +02:00
|
|
|
If ( CountProgramParameters() <> 1 )
|
|
|
|
dummy = MessageRequester("Usage:",
|
|
|
|
"logmonitor <filename>" + Chr(13) +
|
2021-03-30 21:21:53 +02:00
|
|
|
" shows a logfile and prints changes (in realtime) in a window" + Chr(13) +
|
2021-03-29 08:36:45 +02:00
|
|
|
" filename : full or relative path to file",
|
|
|
|
#PB_MessageRequester_Info)
|
|
|
|
End 99
|
|
|
|
EndIf
|
2021-03-22 00:39:55 +01:00
|
|
|
|
|
|
|
; logfile to monitor ...
|
2021-03-29 08:36:45 +02:00
|
|
|
logfile$=ProgramParameter(0)
|
2021-03-22 00:39:55 +01:00
|
|
|
|
|
|
|
;;;;;;;
|
|
|
|
; MAIN
|
|
|
|
;;;;;;;
|
|
|
|
|
2021-03-29 08:36:45 +02:00
|
|
|
; open logfile ...
|
|
|
|
If Not ReadFile(0, logfile$, #PB_File_SharedWrite | #PB_File_NoBuffering)
|
|
|
|
dummy = MessageRequester("ERROR",
|
|
|
|
"cannot open logfile: [ "+logfile$+" ]",
|
|
|
|
#PB_MessageRequester_Error)
|
|
|
|
End 99
|
|
|
|
EndIf
|
|
|
|
|
2021-03-22 00:39:55 +01:00
|
|
|
; open window to hide all other windows on desktop ...
|
2021-03-29 08:36:45 +02:00
|
|
|
OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_BorderLess|#PB_Window_Maximize)
|
2021-03-22 00:39:55 +01:00
|
|
|
StickyWindow(0,#True)
|
|
|
|
SetActiveWindow(0)
|
|
|
|
|
|
|
|
; set colour to windows blue ...
|
|
|
|
SetWindowColor(0, RGB($00,$a2,$ed))
|
|
|
|
|
|
|
|
; Get window size
|
|
|
|
W = WindowWidth(0)
|
|
|
|
H = WindowHeight(0)
|
|
|
|
|
|
|
|
; create text field ...
|
|
|
|
EditorGadget(0, 8, 8, W-16, H-16, #PB_Editor_ReadOnly | #PB_Editor_WordWrap)
|
|
|
|
|
|
|
|
; load system font
|
2021-03-23 18:30:28 +01:00
|
|
|
LoadFont(0, "Consolas", 12)
|
2021-03-22 00:39:55 +01:00
|
|
|
SetGadgetFont(0, FontID(0))
|
|
|
|
|
|
|
|
; goto end of file ...
|
|
|
|
FileSeek(0,Lof(0))
|
|
|
|
|
|
|
|
; print starting message ...
|
2021-03-29 08:36:45 +02:00
|
|
|
AddGadgetItem(0, -1, "===== Monitoring logfile: [ "+logfile$+" ] =====")
|
2021-03-22 00:39:55 +01:00
|
|
|
|
|
|
|
; get filesize ...
|
|
|
|
filesize=Lof(0)
|
|
|
|
Repeat
|
|
|
|
|
|
|
|
; new data ?
|
|
|
|
If ( filesize < Lof(0) )
|
|
|
|
; print new file contents ...
|
|
|
|
Repeat
|
|
|
|
AddGadgetItem(0, -1, ReadString(0))
|
|
|
|
Until Eof(0)
|
|
|
|
filesize=Lof(0)
|
|
|
|
|
|
|
|
; scroll down editor gadget ...
|
|
|
|
SendMessage_(GadgetID(0), #EM_SETSEL,-1,-1)
|
|
|
|
|
|
|
|
; window refresh ...
|
|
|
|
StickyWindow(0,#True)
|
|
|
|
SetActiveWindow(0)
|
|
|
|
|
|
|
|
EndIf
|
|
|
|
|
|
|
|
Until WaitWindowEvent() = #PB_Event_CloseWindow
|
|
|
|
|
2021-03-28 20:51:25 +02:00
|
|
|
; IDE Options = PureBasic 5.71 LTS (Windows - x64)
|
2021-03-29 08:36:45 +02:00
|
|
|
; CursorPosition = 31
|
|
|
|
; FirstLine = 6
|
2021-03-30 21:21:53 +02:00
|
|
|
; EnableXP
|