mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Merge #6354
6354: Add tracing to main rust-analyzer binary r=flodiebold a=flodiebold
This makes `CHALK_DEBUG` logging work again e.g. when running `analysis-stats`, which is very helpful for debugging.
This change shouldn't regress compile times at all. The reason for that is that chalk-solve already pulls in these crates, and while that's behind a feature (mostly for our benefit, I think) we never actually disabled that feature 😅 So alternatively, we could disable the feature and maybe get an improvement in compile times. In my test I just did to see the impact of that, this PR actually compiled faster than the one just removing tracing though, so it's probably not a big deal.
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
This commit is contained in:
commit
91c1af3612
4 changed files with 29 additions and 1 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1372,6 +1372,9 @@ dependencies = [
|
|||
"text_edit",
|
||||
"threadpool",
|
||||
"toolchain",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"tracing-tree",
|
||||
"tt",
|
||||
"vfs",
|
||||
"vfs-notify",
|
||||
|
|
|
@ -17,7 +17,7 @@ ena = "0.14.0"
|
|||
log = "0.4.8"
|
||||
rustc-hash = "1.1.0"
|
||||
scoped-tls = "1"
|
||||
chalk-solve = "0.34"
|
||||
chalk-solve = { version = "0.34", default-features = false }
|
||||
chalk-ir = "0.34"
|
||||
chalk-recursive = "0.34"
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ threadpool = "1.7.1"
|
|||
rayon = "1.5"
|
||||
mimalloc = { version = "0.1.19", default-features = false, optional = true }
|
||||
lsp-server = "0.4.0"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] }
|
||||
tracing-tree = { version = "0.1.4" }
|
||||
|
||||
stdx = { path = "../stdx", version = "0.0.0" }
|
||||
flycheck = { path = "../flycheck", version = "0.0.0" }
|
||||
|
|
|
@ -68,10 +68,32 @@ fn setup_logging(log_file: Option<PathBuf>) -> Result<()> {
|
|||
let filter = env::var("RA_LOG").ok();
|
||||
logger::Logger::new(log_file, filter.as_deref()).install();
|
||||
|
||||
tracing_setup::setup_tracing()?;
|
||||
|
||||
profile::init();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
mod tracing_setup {
|
||||
use tracing::subscriber;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use tracing_subscriber::Registry;
|
||||
use tracing_tree::HierarchicalLayer;
|
||||
|
||||
pub fn setup_tracing() -> super::Result<()> {
|
||||
let filter = EnvFilter::from_env("CHALK_DEBUG");
|
||||
let layer = HierarchicalLayer::default()
|
||||
.with_indent_lines(true)
|
||||
.with_ansi(false)
|
||||
.with_indent_amount(2)
|
||||
.with_writer(std::io::stderr);
|
||||
let subscriber = Registry::default().with(filter).with(layer);
|
||||
subscriber::set_global_default(subscriber)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn run_server() -> Result<()> {
|
||||
log::info!("server will start");
|
||||
|
||||
|
|
Loading…
Reference in a new issue