27 lines
786 B
Python
27 lines
786 B
Python
"""Print a one-line summary for each captured flow.
|
|
|
|
Usage:
|
|
python tools/capture/summarize.py [flows.jsonl] [keyword ...]
|
|
"""
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main() -> None:
|
|
args = sys.argv[1:]
|
|
path = Path(args[0]) if args and args[0].endswith(".jsonl") else Path("data/captures/flows.jsonl")
|
|
keywords = [a.lower() for a in args if not a.endswith(".jsonl")]
|
|
|
|
for i, line in enumerate(path.read_text(encoding="utf-8").splitlines()):
|
|
r = json.loads(line)
|
|
if keywords and not any(k in line.lower() for k in keywords):
|
|
continue
|
|
size = (r["resp_body"] or {}).get("size", 0)
|
|
print(f"{i:4d} {r['ts'][11:]} {r['method']:6s} {r['status']} {size:7d} {r['url'][:150]}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|