mirror of
https://github.com/rizsotto/Bear.git
synced 2026-10-01 11:56:46 +02:00
Bear's log output serves two readers, and one format could not serve both. A user running a build wants terse, program-prefixed messages like every other UNIX tool; a developer debugging Bear wants a rich trace that tells apart the driver, wrapper, and preload processes as their lines interleave on one terminal. The old code had three divergent init sites: the driver used env_logger's default format, which tags each line with the Rust module path rather than the process, so a single process spanning many crates was mislabelled; the wrapper and preload each hand-rolled a timestamped format with duplicated epoch math. Replace all three with one shared initializer in the intercept crate (the only dependency common to every binary). It picks a format from the environment: unset RUST_LOG gives the UNIX user view "prog: message" on stderr with warning:/error: qualifiers; a set RUST_LOG gives the developer view tagging every line with a timestamp, level, process identity plus pid, and source module. Process identities are stable: bear, wrapper, preload. Behavior change worth noting for release: the wrapper and preload previously had no explicit default filter (effectively error level); they now default to warn like the driver, so a rare preload warning (non-UTF-8 popen/system command, or a double-init guard) can reach an intercepted compiler's stderr. This is intentional per the new contract. Governed by the new requirement cli-diagnostic-format, verified by unit tests on the format helpers and integration tests on the format switch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>