Skip to content

Commit d3c02b4

Browse files
authored
Rollup merge of #143180 - jieyouxu:forest, r=Kobzol
Use `tracing-forest` instead of `tracing-tree` for bootstrap tracing I find the `tracing-forest` output easier to comprehend. Note that this is not a strict improvement -- `tracing-forest` output contains some emojis and redundant log levels, but customizing it seems to be... non-trivial. Despite this, I still find `tracing-forest` easier to follow than `tracing-tree`, even when I tried to tune `tracing-tree` output. ### Preview ```bash BOOTSTRAP_TRACING=debug ./x test library/std --dry-run ``` With `tracing-forest` (this PR), it looks like ![Screenshot 2025-06-29 174802](https://github.com/user-attachments/assets/1ab9150f-48f8-4fb3-b004-27bcf8bbc0f5) With `tracing-tree` (before this PR), it looked like ![Screenshot 2025-06-29 175227](https://github.com/user-attachments/assets/659e254d-15ab-47dd-af11-98e2331d4d7a) r? `@Kobzol`
2 parents 1be0c62 + 0cb0b22 commit d3c02b4

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

src/bootstrap/Cargo.lock

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ dependencies = [
1111
"memchr",
1212
]
1313

14+
[[package]]
15+
name = "ansi_term"
16+
version = "0.12.1"
17+
source = "registry+https://github.com/rust-lang/crates.io-index"
18+
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
19+
dependencies = [
20+
"winapi",
21+
]
22+
1423
[[package]]
1524
name = "anstyle"
1625
version = "1.0.10"
@@ -62,8 +71,8 @@ dependencies = [
6271
"toml",
6372
"tracing",
6473
"tracing-chrome",
74+
"tracing-forest",
6575
"tracing-subscriber",
66-
"tracing-tree",
6776
"walkdir",
6877
"windows",
6978
"xz2",
@@ -449,15 +458,6 @@ dependencies = [
449458
"winapi",
450459
]
451460

452-
[[package]]
453-
name = "nu-ansi-term"
454-
version = "0.50.1"
455-
source = "registry+https://github.com/rust-lang/crates.io-index"
456-
checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399"
457-
dependencies = [
458-
"windows-sys 0.52.0",
459-
]
460-
461461
[[package]]
462462
name = "objc2-core-foundation"
463463
version = "0.3.1"
@@ -775,6 +775,26 @@ dependencies = [
775775
"winapi-util",
776776
]
777777

778+
[[package]]
779+
name = "thiserror"
780+
version = "1.0.69"
781+
source = "registry+https://github.com/rust-lang/crates.io-index"
782+
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
783+
dependencies = [
784+
"thiserror-impl",
785+
]
786+
787+
[[package]]
788+
name = "thiserror-impl"
789+
version = "1.0.69"
790+
source = "registry+https://github.com/rust-lang/crates.io-index"
791+
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
792+
dependencies = [
793+
"proc-macro2",
794+
"quote",
795+
"syn",
796+
]
797+
778798
[[package]]
779799
name = "thread_local"
780800
version = "1.1.8"
@@ -837,6 +857,19 @@ dependencies = [
837857
"valuable",
838858
]
839859

860+
[[package]]
861+
name = "tracing-forest"
862+
version = "0.1.6"
863+
source = "registry+https://github.com/rust-lang/crates.io-index"
864+
checksum = "ee40835db14ddd1e3ba414292272eddde9dad04d3d4b65509656414d1c42592f"
865+
dependencies = [
866+
"ansi_term",
867+
"smallvec",
868+
"thiserror",
869+
"tracing",
870+
"tracing-subscriber",
871+
]
872+
840873
[[package]]
841874
name = "tracing-log"
842875
version = "0.2.0"
@@ -855,7 +888,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
855888
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
856889
dependencies = [
857890
"matchers",
858-
"nu-ansi-term 0.46.0",
891+
"nu-ansi-term",
859892
"once_cell",
860893
"regex",
861894
"sharded-slab",
@@ -866,18 +899,6 @@ dependencies = [
866899
"tracing-log",
867900
]
868901

869-
[[package]]
870-
name = "tracing-tree"
871-
version = "0.4.0"
872-
source = "registry+https://github.com/rust-lang/crates.io-index"
873-
checksum = "f459ca79f1b0d5f71c54ddfde6debfc59c8b6eeb46808ae492077f739dc7b49c"
874-
dependencies = [
875-
"nu-ansi-term 0.50.1",
876-
"tracing-core",
877-
"tracing-log",
878-
"tracing-subscriber",
879-
]
880-
881902
[[package]]
882903
name = "typenum"
883904
version = "1.17.0"

src/bootstrap/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-run = "bootstrap"
77

88
[features]
99
build-metrics = ["sysinfo"]
10-
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:tracing-tree"]
10+
tracing = ["dep:tracing", "dep:tracing-chrome", "dep:tracing-subscriber", "dep:tracing-forest"]
1111

1212
[lib]
1313
path = "src/lib.rs"
@@ -64,7 +64,7 @@ sysinfo = { version = "0.35.0", default-features = false, optional = true, featu
6464
tracing = { version = "0.1", optional = true, features = ["attributes"] }
6565
tracing-chrome = { version = "0.7", optional = true }
6666
tracing-subscriber = { version = "0.3", optional = true, features = ["env-filter", "fmt", "registry", "std"] }
67-
tracing-tree = { version = "0.4.0", optional = true }
67+
tracing-forest = { version = "0.1.6", optional = true, default-features = false, features = ["smallvec", "ansi", "env-filter"] }
6868

6969
[target.'cfg(windows)'.dependencies.junction]
7070
version = "1.0.0"

src/bootstrap/src/bin/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,11 @@ fn check_version(config: &Config) -> Option<String> {
217217
// "tracing", instrument(..))]`.
218218
#[cfg(feature = "tracing")]
219219
fn setup_tracing() -> impl Drop {
220+
use tracing_forest::ForestLayer;
220221
use tracing_subscriber::EnvFilter;
221222
use tracing_subscriber::layer::SubscriberExt;
222223

223224
let filter = EnvFilter::from_env("BOOTSTRAP_TRACING");
224-
// cf. <https://docs.rs/tracing-tree/latest/tracing_tree/struct.HierarchicalLayer.html>.
225-
let layer = tracing_tree::HierarchicalLayer::default().with_targets(true).with_indent_amount(2);
226225

227226
let mut chrome_layer = tracing_chrome::ChromeLayerBuilder::new().include_args(true);
228227

@@ -233,7 +232,8 @@ fn setup_tracing() -> impl Drop {
233232

234233
let (chrome_layer, _guard) = chrome_layer.build();
235234

236-
let registry = tracing_subscriber::registry().with(filter).with(layer).with(chrome_layer);
235+
let registry =
236+
tracing_subscriber::registry().with(filter).with(ForestLayer::default()).with(chrome_layer);
237237

238238
tracing::subscriber::set_global_default(registry).unwrap();
239239
_guard

0 commit comments

Comments
 (0)