You can create a script input that will remember where it left off and print the difference.
Below is an example script
import hashlib
from datetime import datetime, timedelta
from itertools import islice
from re import search
log_file="sample.log"
try:
with open(hashlib.sha256(log_file.encode()).hexdigest()) as state:
last_position=int(state.readline())
except IOError:
last_position=0
data_pattern = r"^(\d+\.\d+) (.+)$"
date_pattern = r"^\d+\.\d+ (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})"
with open(log_file, 'r') as f:
data=search(date_pattern, f.readline())
datetime_object = datetime.strptime(data.group(1), r'%Y-%m-%d %H:%M:%S')
f.seek(last_position)
for line in f:
data = search(data_pattern, line)
if data is not None:
print('{} {}'.format(
datetime_object+timedelta(seconds=float(data.group(1))),
data.group(2)))
last_position=f.tell()
try:
with open(hashlib.sha256(log_file.encode()).hexdigest(),'w') as state:
state.write('{}'.format(last_position))
except IOError:
print("Error writing state file")
Example output
2020-02-05 17:35:53.012000 2020-02-05 17:35:53; Factorio 0.18.3 (build 49258, win64, alpha)
2020-02-05 17:35:53.013000 Operating system: Windows 10 (build 18363)
2020-02-05 17:35:53.013000 Program arguments: "E:\GOG\Factorio\bin\x64\factorio.exe" "--force-opengl"
2020-02-05 17:35:53.013000 Read data path: E:/GOG/Factorio/data
2020-02-05 17:35:53.013000 Write data path: C:/Users/Nate/AppData/Roaming/Factorio [626596/1907076MB]
2020-02-05 17:35:53.013000 Binaries path: E:/GOG/Factorio/bin
2020-02-05 17:35:53.032000 System info: [CPU: AMD Ryzen 7 2700X Eight-Core Processor, 16 cores, RAM: 6553/16310 MB, page: 9579/24406 MB, virtual: 4251/134217727 MB, extended virtual: 0 MB]
2020-02-05 17:35:53.032000 Display options: [FullScreen: 1] [VSync: 1] [UIScale: custom (150.0%)] [Native DPI: 1] [Screen: 255] [Special: lmw] [Lang: en]
2020-02-05 17:35:53.036000 Available displays: 1
2020-02-05 17:35:53.036000 [0]: \\.\DISPLAY1 - NVIDIA GeForce GTX 1070 {0x05, [0,0], 2560x1440, 32bit, 59Hz}
2020-02-05 17:35:53.684000 Initialised OpenGL:[0] GeForce GTX 1070/PCIe/SSE2; driver: 3.3.0 NVIDIA 432.00
2020-02-05 17:35:53.684000 [Extensions] s3tc:yes; KHR_debug:yes; ARB_clear_texture:yes, ARB_copy_image:yes
2020-02-05 17:35:53.684000 [Version] 3.3
2020-02-05 17:35:53.684000 Verbose GraphicsInterfaceOpenGL.cpp:896: [Caps] Tex:32768, TexArr:2048, TexBufSz:131072kB; TexUnits:192; UboSz:64kB
2020-02-05 17:35:53.684000 Graphics settings preset: very-high
2020-02-05 17:35:53.684000 Dedicated video memory size 8192 MB
2020-02-05 17:35:54.095000 Verbose PipelineStateObject.cpp:85: Time to load shaders: 0.411126 seconds.
2020-02-05 17:35:54.149000 Desktop composition is active.
2020-02-05 17:35:54.150000 Graphics options: [Graphics quality: high] [Video memory usage: all] [Light scale: 100%] [DXT: high-quality] [Color: 32bit]
2020-02-05 17:35:54.150000 [Max threads (load/render): 32/16] [Max texture size: 0] [Tex.Stream.: 0] [Rotation quality: normal] [Other: STDC] [B:0,C:0,S:100]
The idea of the script is to be expandable so that with slight modifications you can modify the script to receive parameters and keep state in a convenient location
... View more