Skip to content

Commit 360d2db

Browse files
factorydroidechobt
authored andcommitted
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 ac8decf commit 360d2db

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
@@ -566,10 +566,10 @@ impl RunCli {
566566

567567
match self.format {
568568
OutputFormat::Json => {
569-
eprintln!("{}", serde_json::to_string(&event_json)?);
569+
println!("{}", serde_json::to_string(&event_json)?);
570570
}
571571
OutputFormat::Jsonl => {
572-
eprintln!("{}", serde_json::to_string(&event_json)?);
572+
println!("{}", serde_json::to_string(&event_json)?);
573573
}
574574
_ => {}
575575
}
@@ -648,7 +648,7 @@ impl RunCli {
648648
"message": e.message,
649649
"session_id": session_id,
650650
});
651-
eprintln!("{}", serde_json::to_string(&err_json)?);
651+
println!("{}", serde_json::to_string(&err_json)?);
652652
} else {
653653
eprintln!(
654654
"{}Error:{} {}",

0 commit comments

Comments
 (0)