Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions shared/subspace-process/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ include = [
]

[dependencies]
# Substrate crates (and therefore their `console`-styled log messages) still link
# against console 0.15.x, whose color state is independent of console 0.16.x.
# Depend on both so `init_logger` can disable colors in each version's global state.
console.workspace = true
console-0-15 = { package = "console", version = "0.15.11" }
fdlimit.workspace = true
futures.workspace = true
supports-color.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions shared/subspace-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ pub fn init_logger() {
// sc_informant and other substrate crates colorize log content via `console`;
// tracing-subscriber 0.3.20+ escapes those embedded ANSI codes into literal `\x1b[`
// text in the message. Turn console color off at the source so nothing is emitted.
//
// The workspace uses console 0.16.x, but substrate still links against console
// 0.15.x, which keeps its own global color state. Disable colors in both so the
// workaround remains effective for substrate's messages.
console::set_colors_enabled(false);
console::set_colors_enabled_stderr(false);
console_0_15::set_colors_enabled(false);
console_0_15::set_colors_enabled_stderr(false);

// TODO: Workaround for https://github.com/tokio-rs/tracing/issues/2214, also on
// Windows terminal doesn't support the same colors as bash does
Expand Down
10 changes: 9 additions & 1 deletion shared/subspace-process/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ fn init_logger_disables_console_ansi() {
let styled = format!("{}", console::style("x").white().bold());
assert_eq!(
styled, "x",
"console emitted ANSI after init_logger: {styled:?}"
"console 0.16 emitted ANSI after init_logger: {styled:?}"
);

// Substrate still links against console 0.15.x; ensure its global color state is
// disabled too.
let styled_legacy = format!("{}", console_0_15::style("x").white().bold());
assert_eq!(
styled_legacy, "x",
"console 0.15 emitted ANSI after init_logger: {styled_legacy:?}"
);
}

Expand Down
Loading