Skip to content

fbuild-cli output discipline: 248 println → tracing-backed bridge (#844) #848

Description

@zackees

Goal

248 println! / eprintln! calls in fbuild-cli are how CLI output reaches the user today. This is intentional but uncontrolled — there's no structured separation between progress, results, errors, and diagnostics. Replace with a curated fbuild_cli::output::* API backed by tracing so users (and CI consumers) can filter / format.

Sub-issue of #844.

Why it matters

  1. JSON / machine-readable output — currently impossible without a workspace-wide rewrite. Hard for CI to consume.
  2. Verbosity control--verbose / --quiet flags exist but are not consistently honored.
  3. Linker debug traces — 12+ println! calls in per-platform linkers (avr/, ch32v/, esp8266/, generic_arm/, nrf52/, renesas/, sam/, silabs/, teensy/) leak debug output to stdout in normal builds.
  4. Color discipline — currently every CLI subcommand handles ANSI separately. Centralized output makes --color={auto,always,never} enforceable.

Bridge API

// crates/fbuild-cli/src/output.rs
pub fn progress(msg: impl Display);  // tracing::info!
pub fn result(msg: impl Display);     // stdout, always shown (the actual output)
pub fn warn(msg: impl Display);       // tracing::warn!
pub fn error(msg: impl Display);      // stderr + tracing::error!
pub fn debug(msg: impl Display);      // tracing::debug!

For linker debug traces (separately in fbuild-build):

  • Replace println!("[linker] {}", ...) with tracing::debug!(target = "fbuild_build::linker", ...).

Migration phases

  1. Phase 1 — fbuild-cli output API (this sub-issue):
    • Add crates/fbuild-cli/src/output.rs with the curated API.
    • Migrate all 248 println! / eprintln! calls.
    • Add ban_print_in_fbuild_cli lint scoped to crates/fbuild-cli/src/** excluding the bridge module.
  2. Phase 2 — linker debug traces (could be a separate follow-up):
    • Replace 12+ println!/eprintln! calls in crates/fbuild-build/src/*/linker.rsand per-platform orchestrators withtracing::debug!`.
    • Add ban_print_in_fbuild_build lint (allowlist: none).

Lint

ban_print_in_production — file-path scoped to crates/fbuild-cli/src/** and crates/fbuild-build/src/**, excluding the bridge module in fbuild-cli.

Acceptance

  • fbuild_cli::output::* API exists with tests
  • All 248 cli-side println/eprintln calls migrated
  • All 12+ linker debug traces moved to tracing::debug!
  • ban_print_in_production lint deployed with allowlist exactly = [crates/fbuild-cli/src/output.rs]
  • --color={auto,always,never} flag works consistently across all subcommands
  • --quiet and --verbose flags consistently routed through tracing's level filter

References: #844.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions