[Bug] Colored/dimmed log messages do not work as expected
In most recent staging, the use of Colorize::dimmed in logs broke. Now, we get outputs like the following:
INFO snarkos_node_bft::gateway: Connected to 2 validators \x1b[2m(of 3 bonded validators)\x1b[0m
DEBUG snarkos_node_bft::gateway: \x1b[2m 127.0.0.1:5000 - aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px\x1b[0m
DEBUG snarkos_node_bft::gateway: \x1b[2m 127.0.0.1:5001 - aleo1s3ws5tra87fjycnjrwsjcrnw2qxr8jfqqdugnf0xzqqw29q9m5pqem2u4t\x1b[0m
INFO snarkos_node_bft::gateway: Not connected to 1 validators \x1b[2m(of 3 bonded validators)\x1b[0m
DEBUG snarkos_node_bft::gateway: \x1b[2m Not connected to aleo12ux3gdauck0v60westgcpqj7v8rrcr3v346e4jtq04q7kkt22czsh808v2\x1b[0m
This is low priority and I did not have much time to debug it, but a quick bisect told me 1702ed644 is the first bad commit. Unfortunately, that commit is a snarkVM revision bump that includes many changes to snarkVM, so more digging is needed.
More Context
We log using tracing-subscriber which has an ansi feature to enable the needed ANSI escape codes. The feature is still enabled, from what I can tell, but the functionality also needs to be switched on at runtime. The current disables ANSI escape codes if it detects that stdout is not a TTY (e.g., when piping output to a file).
Most likely something about how we set up the log subscriber changed, or the detection of a terminal/TTY broke. We recently updated the crossterm dependency, which could also have caused issues.
Related: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.20.
Related: https://github.com/tokio-rs/tracing/releases/tag/tracing-subscriber-0.3.20.
They indeed removed this feature in a patch release. Other projects seem to run into the same issue as us: https://github.com/tokio-rs/tracing/issues/3378