fix(cli): write JSON output to stdout instead of stderr#13
Merged
Conversation
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.
17bdd88 to
fed987e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using
--jsonor--jsonloutput format withcortex run, JSON event objects were incorrectly written to stderr instead of stdout. This caused malformed output when piping to tools likejq.Changes
eprintln!toprintln!for JSON event output in the main event loopeprintln!toprintln!for error JSON output when in JSON modeRelated
Fixes PlatformNetwork/bounty-challenge#1495