Skip to content

Commit a2d967f

Browse files
committed
servoshell: compose tracing layers with a Registry
Signed-off-by: Delan Azabani <[email protected]>
1 parent f2f5a8a commit a2d967f

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed

Cargo.lock

Lines changed: 38 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ports/servoshell/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ shellwords = "1.0.0"
106106
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
107107
tinyfiledialogs = "3.0"
108108
tracing = { workspace = true }
109-
tracing-subscriber = { workspace = true }
109+
tracing-subscriber = { workspace = true, features = ["env-filter"] }
110110
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
111111
winit = "0.29.10"
112112

ports/servoshell/desktop/cli.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@ use getopts::Options;
88
use log::error;
99
use servo::config::opts::{self, ArgumentParsingResult};
1010
use servo::servo_config::pref;
11+
use tracing_subscriber::layer::SubscriberExt;
12+
use tracing_subscriber::util::SubscriberInitExt;
13+
use tracing_subscriber::EnvFilter;
1114

1215
use crate::desktop::app::App;
1316
use crate::panic_hook;
1417

1518
pub fn main() {
1619
crate::crash_handler::install();
1720

18-
tracing_subscriber::fmt::init();
21+
// Set up a custom tracing subscriber that behaves like the default fmt
22+
// subscriber, but also lets us insert our own layers for things like
23+
// compositor-to-constellation and script-to-constellation logging.
24+
// <https://tokio.rs/tokio/topics/tracing>
25+
// <https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/fmt/index.html#composing-layers>
26+
// FIXME: our event tracing log targets are considered “invalid filter directive”
27+
// <https://book.servo.org/hacking/debugging.html#event-tracing>
28+
let env_filter_layer = EnvFilter::from_default_env();
29+
let fmt_layer = tracing_subscriber::fmt::layer();
30+
tracing_subscriber::registry()
31+
.with(env_filter_layer)
32+
.with(fmt_layer)
33+
.init();
1934

2035
crate::resources::init();
2136

0 commit comments

Comments
 (0)