mitmproxy/test/helper_tools/loggrep.py

18 lines
412 B
Python
Raw Normal View History

2021-05-11 14:03:39 +00:00
#!/usr/bin/env python3
import fileinput
import sys
2021-06-09 21:59:44 +00:00
import re
2021-05-11 14:03:39 +00:00
if __name__ == "__main__":
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} port filenames")
sys.exit()
port = sys.argv[1]
matches = False
for line in fileinput.input(sys.argv[2:]):
2021-06-09 21:59:44 +00:00
if re.match(r"^\[|(\d+\.){3}", line):
2021-05-11 14:03:39 +00:00
matches = port in line
if matches:
print(line, end="")