I think you're correct, you would need to add marks to the log files or do something like this:
As long as you're running in a "Houdini Service Block" you can at the start of the loop store the current number of lines in the log.
Then at the end of the block extract the lines from the stored line number to the end of the file (need to reset the client make it write to the log).
Script at start of loop:
import os
import sys
import re
command_string = " ".join(sys.argv)
work_item.setStringAttrib("command_string", command_string)
# Parse command string to extract --logfile {path}
log_file_match = re.search(r"--logfile\s+(\S+)", command_string)
if log_file_match:
log_file = log_file_match.group(1)
work_item.setStringAttrib("log_file", log_file)
if os.path.isfile(log_file):
with open(log_file) as f:
current_line = sum(1 for _ in f)
work_item.setIntAttrib("log_start", current_line)
else:
work_item.setIntAttrib("log_start", 1)
Script at end of loop (With the parm "Reset Service" set to "Reset Client" - "Before Cook"):
from itertools import islice
log_start = work_item.intAttribValue("log_start")
with open(work_item.stringAttribValue("log_file")) as f:
lines = list(islice(f, log_start+2, None)) # Skip the first two lines
work_item.setStringAttrib("log_contents",'\n'.join(lines))
Attaching my mock-up scene