Skip to content

logger: write warnings to stderr, not stdout#197

Open
selimdev00 wants to merge 1 commit into
LarsCowe:mainfrom
selimdev00:fix/logger-warn-stderr
Open

logger: write warnings to stderr, not stdout#197
selimdev00 wants to merge 1 commit into
LarsCowe:mainfrom
selimdev00:fix/logger-warn-stderr

Conversation

@selimdev00

Copy link
Copy Markdown

Problem

logger.warn writes to stdout via console.log:

export function warn(message: string): void {
  if (quiet) return;
  console.log(chalk.yellow(message));
}

Warnings are diagnostics, not results, so they belong on stderr. Emitting them on stdout corrupts any machine-readable stdout - e.g. a --json payload or a value being piped/captured - by interleaving a yellow warning line into it. Several real warnings flow through here: corrupt bmalph/config.json, corrupt bmalph/state/current-phase.json, malformed _bmad/config.yaml, and the platform-resolution fallback. A consumer parsing stdout JSON can hit a syntax error purely because the project state was slightly off.

Fix

console.error(chalk.yellow(message));

info/debug are unchanged. The quiet gate is unchanged. This is purely a stream correctness fix.

Tests

  • Updated logger tests: warn now asserts on stderr and additionally asserts nothing is written to stdout.
  • Updated the three suites that captured warnings via a console.log spy (config, state, platform resolve) to spy on console.error - which also documents that those warnings were previously landing on stdout.
  • Full unit suite passes (1836).

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.

1 participant