Skip to content

Commit 17bdd88

Browse files
committed
fix(cli): write JSON output to stdout instead of stderr
Fixes bounty issue #1495 When using --json or --jsonl output format, JSON event objects were being written to stderr (eprintln!) instead of stdout (println!). This caused malformed output when piping to tools like jq, as the JSON events would appear in the terminal while the final result was piped to the destination. Changed eprintln! to println! for JSON event output and error JSON output to ensure all JSON data goes to stdout for proper piping support.
1 parent 8f839ec commit 17bdd88

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

cortex-cli/src/run_cmd.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,10 @@ impl RunCli {
554554

555555
match self.format {
556556
OutputFormat::Json => {
557-
eprintln!("{}", serde_json::to_string(&event_json)?);
557+
println!("{}", serde_json::to_string(&event_json)?);
558558
}
559559
OutputFormat::Jsonl => {
560-
eprintln!("{}", serde_json::to_string(&event_json)?);
560+
println!("{}", serde_json::to_string(&event_json)?);
561561
}
562562
_ => {}
563563
}
@@ -636,7 +636,7 @@ impl RunCli {
636636
"message": e.message,
637637
"session_id": session_id,
638638
});
639-
eprintln!("{}", serde_json::to_string(&err_json)?);
639+
println!("{}", serde_json::to_string(&err_json)?);
640640
} else {
641641
eprintln!(
642642
"{}Error:{} {}",

0 commit comments

Comments
 (0)