in scripts/qlog_parser.py [0:0]
def main():
global last_scid_
parser = argparse.ArgumentParser()
parser.add_argument("--clog", help="xquic client log file")
parser.add_argument("--slog", help="xquic server log file")
parser.add_argument("--qlog_path", help="output json file, endswith .json", default="demo_qlog.json")
args = parser.parse_args()
if (args.clog is None) and (args.slog is None):
print("Usage: must provide either --clog or --slog argument")
sys.exit(1)
if (args.clog is not None) and (not os.path.isfile(args.clog)):
print(f"Error: The log '{args.clog}' does not exist.")
sys.exit(1)
if (args.slog is not None) and (not os.path.isfile(args.slog)):
print(f"Error: The log '{args.slog}' does not exist.")
sys.exit(1)
if (args.qlog_path is not None) and (not args.qlog_path.endswith(".json")):
print(f"Error: The qlog_path should endswith .json.")
sys.exit(1)
data = { "qlog_version": "0.4",
"qlog_format": "JSON",
"title": "xquic qlog",
"description": "this is a demo qlog json of qlog-draft-07",
"traces": []
}
if(args.slog is not None):
server_traces = endpoint_events_extraction(args.slog, "server")
data["traces"] += server_traces
if(args.clog is not None):
client_traces = endpoint_events_extraction(args.clog, "client")
data["traces"] += client_traces
json_output = json.dumps(data, indent=4)
with open(args.qlog_path, 'w') as out_file:
out_file.write(json_output)