diff --git a/Cargo.lock b/Cargo.lock index fb55c8af922..de79e18f122 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4260,6 +4260,15 @@ dependencies = [ "tendril", ] +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "matches" version = "0.1.10" @@ -5803,7 +5812,16 @@ dependencies = [ "aho-corasick", "memchr", "regex-automata 0.4.8", - "regex-syntax", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", ] [[package]] @@ -5823,9 +5841,15 @@ checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.8.5", ] +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + [[package]] name = "regex-syntax" version = "0.8.5" @@ -7533,10 +7557,14 @@ version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex", "sharded-slab", "smallvec", "thread_local", + "tracing", "tracing-core", "tracing-log", ] diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index ea2e5584640..a1d0cbf3829 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -67,7 +67,7 @@ url = { workspace = true } servo-media = { workspace = true } tokio = { workspace = true } tracing = { workspace = true, optional = true } -tracing-subscriber = { workspace = true, optional = true } +tracing-subscriber = { workspace = true, optional = true, features = ["env-filter"] } tracing-perfetto = { workspace = true, optional = true } [target.'cfg(target_os = "android")'.dependencies] diff --git a/ports/servoshell/lib.rs b/ports/servoshell/lib.rs index c28ccbf79cd..ed29f6284e3 100644 --- a/ports/servoshell/lib.rs +++ b/ports/servoshell/lib.rs @@ -44,11 +44,11 @@ pub fn main() { pub fn init_tracing() { #[cfg(feature = "tracing")] { + use tracing_subscriber::layer::SubscriberExt; let subscriber = tracing_subscriber::registry(); #[cfg(feature = "tracing-perfetto")] let subscriber = { - use tracing_subscriber::layer::SubscriberExt; // Set up a PerfettoLayer for performance tracing. // The servo.pftrace file can be uploaded to https://ui.perfetto.dev for analysis. let file = std::fs::File::create("servo.pftrace").unwrap(); @@ -59,11 +59,18 @@ pub fn init_tracing() { #[cfg(feature = "tracing-hitrace")] let subscriber = { - use tracing_subscriber::layer::SubscriberExt; // Set up a HitraceLayer for performance tracing. subscriber.with(HitraceLayer::default()) }; + // Filter events and spans by the directives in SERVO_TRACING, using EnvFilter as a global filter. + // + let filter = tracing_subscriber::EnvFilter::builder() + .with_default_directive(tracing::level_filters::LevelFilter::OFF.into()) + .with_env_var("SERVO_TRACING") + .from_env_lossy(); + let subscriber = subscriber.with(filter); + // Same as SubscriberInitExt::init, but avoids initialising the tracing-log compat layer, // since it would break Servo’s FromScriptLogger and FromCompositorLogger. // diff --git a/servo-tidy.toml b/servo-tidy.toml index 04db7e8fa5f..7fbfda0422d 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -76,6 +76,11 @@ packages = [ # tracing-subscriber -> matchers -> regex-automata 0.1.0 "regex-automata", + # tracing-subscriber (tokio-rs/tracing#3033) uses old version + # regex [-> regex-automata 0.4.7] -> regex-syntax 0.8.4 + # tracing-subscriber -> matchers -> regex-automata 0.1.0 -> regex-syntax 0.6.29 + "regex-syntax", + # gilrs is on 0.10.0, but Servo is still on 0.9.4 "core-foundation",