]> git.lizzy.rs Git - rust.git/commitdiff
Add tracing to main rust-analyzer binary
authorFlorian Diebold <florian.diebold@freiheit.com>
Fri, 23 Oct 2020 15:07:06 +0000 (17:07 +0200)
committerFlorian Diebold <flodiebold@gmail.com>
Sun, 25 Oct 2020 12:53:38 +0000 (13:53 +0100)
Cargo.lock
crates/hir_ty/Cargo.toml
crates/rust-analyzer/Cargo.toml
crates/rust-analyzer/src/bin/main.rs

index efabcf2c5a1242c9f3a726b7cbea39811f3c35be..5c7bcb17b06b110a9cdce908e134d07753dc04cd 100644 (file)
@@ -1372,6 +1372,9 @@ dependencies = [
  "text_edit",
  "threadpool",
  "toolchain",
+ "tracing",
+ "tracing-subscriber",
+ "tracing-tree",
  "tt",
  "vfs",
  "vfs-notify",
index be7c812cb63f836b6f4206e546ce7437f90e0f0f..367a1b98dcdc76e859341037589c31dca1340c96 100644 (file)
@@ -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"
 
index 2f0fa97262d1c856cf703c4b286fad4cd8847696..975b24aaf1b92d62286c97a9e0e07b7ac1ede4c1 100644 (file)
@@ -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" }
index 97b246a322580c9c4c05409f9dfd76da28153f8e..4175e569e5d3ba58d1147670e1cfcc9d77d1627e 100644 (file)
@@ -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");