Repository navigation
fix(cli): write console logs to stderr so --json output stays parseable - #1471
Merged
Merged
Conversation
…le (#1461) The console layer had no writer and defaulted to stdout, so any WARN or ERROR was printed in front of the command's own output and broke json.loads(stdout). Send it to stderr; the file layer is unchanged.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
The CLI console log layer (
crates/uteke-cli/src/logging.rs) now writes to stderr (.with_writer(std::io::stderr)). The file layer, the log levels and the command output are unchanged. New integration testcrates/uteke-cli/tests/json_output_stays_clean.rs, plus a CHANGELOG entry.Closes #1461.
Why
The console layer was built with
tracing_subscriber::fmt::layer()and no writer, which defaults to stdout. Any WARN or ERROR, for example a failed embedding, was printed in front of the command's own output. With--json,json.loads(stdout)then failed: scripts, agents and the benchmark harness parse that output.It matters most exactly when something goes wrong. Found while testing the
ORT_LIB_PATHfix: four coloured log lines came before the JSON line.Other diagnostics already go to stderr on purpose (the namespace deprecation notice uses
eprintln!).Testing
ORT_LIB_PATHpointing at a missing file,uteke --json rememberstores the memory but logs WARN/ERROR lines. Before the fix the test failed because stdout started with the colour-coded log lines. After the fix, stdout is exactly one JSON value (embedding_written: false) and the WARN/ERROR lines are on stderr. It needs no ONNX runtime, so it runs in CI.cargo test -p uteke-cli --locked: all pass (135 unit tests plus the integration tests).cargo fmt --all -- --checkandcargo clippy --all-targets --locked -- -D warnings: clean.uteke-serveis unchanged on purpose: a daemon logs to stdout, anddocker logsrelies on it.uteke-mcpdoes not initialise tracing, so its stdio protocol channel is unaffected.