Skip to content

fix(cli): write console logs to stderr so --json output stays parseable - #1471

Merged
ajianaz merged 2 commits into
developfrom
fix/cli-logs-to-stderr
Oct 15, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/cli-logs-to-stderr

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

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 test crates/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_PATH fix: four coloured log lines came before the JSON line.

Other diagnostics already go to stderr on purpose (the namespace deprecation notice uses eprintln!).

Testing

  • New test, red first: with ORT_LIB_PATH pointing at a missing file, uteke --json remember stores 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 -- --check and cargo clippy --all-targets --locked -- -D warnings: clean.
  • uteke-serve is unchanged on purpose: a daemon logs to stdout, and docker logs relies on it. uteke-mcp does not initialise tracing, so its stdio protocol channel is unaffected.

…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.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 1738e7c into develop Oct 15, 2026
15 checks passed
@ajianaz
ajianaz deleted the fix/cli-logs-to-stderr branch October 15, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: tracing output goes to stdout and corrupts --json output

1 participant