here is a script. import sys def summarize(path): total = 0 errors = 0 for line in open(path): total += 1 if "ERROR" in line: errors += 1 print(f"lines {total} errors {errors}") summarize(sys.argv[1]) add a --json flag that prints the same two numbers as json instead. return the whole script.