From dedc91e2cf6a9ad5dd312a2c917fc3ad2dac0d83 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Wed, 24 Jan 2024 11:16:41 +0100 Subject: [PATCH] use json lines --- tracing-trace/src/bin/trace-to-callstats.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tracing-trace/src/bin/trace-to-callstats.rs b/tracing-trace/src/bin/trace-to-callstats.rs index 3644b7bff..631cdbb45 100644 --- a/tracing-trace/src/bin/trace-to-callstats.rs +++ b/tracing-trace/src/bin/trace-to-callstats.rs @@ -1,6 +1,8 @@ use std::ffi::OsString; use std::io::Write; +use serde_json::json; + fn main() { let input_file = std::env::args_os().nth(1).expect("missing file"); let input = @@ -11,6 +13,9 @@ fn main() { output_file.push("callstats-"); output_file.push(input_file); let mut output_file = std::io::BufWriter::new(std::fs::File::create(output_file).unwrap()); - serde_json::to_writer(&mut output_file, &profile).unwrap(); + for (key, value) in profile { + serde_json::to_writer(&mut output_file, &json!({key: value})).unwrap(); + writeln!(&mut output_file).unwrap(); + } output_file.flush().unwrap(); }