Rollup merge of #75143 - oli-obk:tracing, r=RalfJung
Use `tracing` spans to trace the entire MIR interp stack r? @RalfJung While being very verbose, this allows really good tracking of what's going on. While I considered schemes like the previous indenter that we had (which we could get by using the `tracing-tree` crate), this will break down horribly with things like multithreaded rustc. Instead, we can now use `RUSTC_LOG` to restrict the things being traced. You could specify a filter in a way that only shows the logging of a specific frame.  If we lower the span's level to `debug`, then in `info` level logging we'd not see the frames, but in `debug` level we would see them. The filtering rules in `tracing` are super powerful, but I'm not sure if we can specify a filter so we do see `debug` level events, but *not* the `frame` spans. The documentation at https://docs.rs/tracing-subscriber/0.2.10/tracing_subscriber/struct.EnvFilter.html makes me think that we can only turn on things, not turn off things at a more precise level. cc @hawkw
This commit is contained in:
commit
6e25418474
6 changed files with 74 additions and 40 deletions
|
@ -11,6 +11,7 @@ crate-type = ["dylib"]
|
|||
libc = "0.2"
|
||||
tracing = { version = "0.1.18" }
|
||||
tracing-subscriber = { version = "0.2.10", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
|
||||
tracing-tree = "0.1.6"
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
|
|
|
@ -1251,11 +1251,21 @@ pub fn init_env_logger(env: &str) {
|
|||
Ok(s) if s.is_empty() => return,
|
||||
Ok(_) => {}
|
||||
}
|
||||
let builder = tracing_subscriber::FmtSubscriber::builder();
|
||||
let filter = tracing_subscriber::EnvFilter::from_env(env);
|
||||
let layer = tracing_tree::HierarchicalLayer::default()
|
||||
.with_indent_lines(true)
|
||||
.with_ansi(true)
|
||||
.with_targets(true)
|
||||
.with_thread_ids(true)
|
||||
.with_thread_names(true)
|
||||
.with_wraparound(10)
|
||||
.with_verbose_exit(true)
|
||||
.with_verbose_entry(true)
|
||||
.with_indent_amount(2);
|
||||
|
||||
let builder = builder.with_env_filter(tracing_subscriber::EnvFilter::from_env(env));
|
||||
|
||||
builder.init()
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer);
|
||||
tracing::subscriber::set_global_default(subscriber).unwrap();
|
||||
}
|
||||
|
||||
pub fn main() -> ! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue