diff options
author | Florian Diebold <[email protected]> | 2020-10-23 16:07:06 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-10-25 12:53:38 +0000 |
commit | 39dfca23f1634c1e21819806bdd696c8096d0f0f (patch) | |
tree | 06fc97459be2a8a210d03a43542c9297a9d8d4f6 /crates | |
parent | 34034e4a64cd49e82171601e55ab6dd1d5b52cd4 (diff) |
Add tracing to main rust-analyzer binary
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir_ty/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/bin/main.rs | 22 |
3 files changed, 26 insertions, 1 deletions
diff --git a/crates/hir_ty/Cargo.toml b/crates/hir_ty/Cargo.toml index be7c812cb..367a1b98d 100644 --- a/crates/hir_ty/Cargo.toml +++ b/crates/hir_ty/Cargo.toml | |||
@@ -17,7 +17,7 @@ ena = "0.14.0" | |||
17 | log = "0.4.8" | 17 | log = "0.4.8" |
18 | rustc-hash = "1.1.0" | 18 | rustc-hash = "1.1.0" |
19 | scoped-tls = "1" | 19 | scoped-tls = "1" |
20 | chalk-solve = "0.34" | 20 | chalk-solve = { version = "0.34", default-features = false } |
21 | chalk-ir = "0.34" | 21 | chalk-ir = "0.34" |
22 | chalk-recursive = "0.34" | 22 | chalk-recursive = "0.34" |
23 | 23 | ||
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 2f0fa9726..975b24aaf 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -32,6 +32,9 @@ threadpool = "1.7.1" | |||
32 | rayon = "1.5" | 32 | rayon = "1.5" |
33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } | 33 | mimalloc = { version = "0.1.19", default-features = false, optional = true } |
34 | lsp-server = "0.4.0" | 34 | lsp-server = "0.4.0" |
35 | tracing = "0.1" | ||
36 | tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] } | ||
37 | tracing-tree = { version = "0.1.4" } | ||
35 | 38 | ||
36 | stdx = { path = "../stdx", version = "0.0.0" } | 39 | stdx = { path = "../stdx", version = "0.0.0" } |
37 | flycheck = { path = "../flycheck", version = "0.0.0" } | 40 | flycheck = { path = "../flycheck", version = "0.0.0" } |
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs index 97b246a32..4175e569e 100644 --- a/crates/rust-analyzer/src/bin/main.rs +++ b/crates/rust-analyzer/src/bin/main.rs | |||
@@ -68,10 +68,32 @@ fn setup_logging(log_file: Option<PathBuf>) -> Result<()> { | |||
68 | let filter = env::var("RA_LOG").ok(); | 68 | let filter = env::var("RA_LOG").ok(); |
69 | logger::Logger::new(log_file, filter.as_deref()).install(); | 69 | logger::Logger::new(log_file, filter.as_deref()).install(); |
70 | 70 | ||
71 | tracing_setup::setup_tracing()?; | ||
72 | |||
71 | profile::init(); | 73 | profile::init(); |
72 | Ok(()) | 74 | Ok(()) |
73 | } | 75 | } |
74 | 76 | ||
77 | mod tracing_setup { | ||
78 | use tracing::subscriber; | ||
79 | use tracing_subscriber::layer::SubscriberExt; | ||
80 | use tracing_subscriber::EnvFilter; | ||
81 | use tracing_subscriber::Registry; | ||
82 | use tracing_tree::HierarchicalLayer; | ||
83 | |||
84 | pub fn setup_tracing() -> super::Result<()> { | ||
85 | let filter = EnvFilter::from_env("CHALK_DEBUG"); | ||
86 | let layer = HierarchicalLayer::default() | ||
87 | .with_indent_lines(true) | ||
88 | .with_ansi(false) | ||
89 | .with_indent_amount(2) | ||
90 | .with_writer(std::io::stderr); | ||
91 | let subscriber = Registry::default().with(filter).with(layer); | ||
92 | subscriber::set_global_default(subscriber)?; | ||
93 | Ok(()) | ||
94 | } | ||
95 | } | ||
96 | |||
75 | fn run_server() -> Result<()> { | 97 | fn run_server() -> Result<()> { |
76 | log::info!("server will start"); | 98 | log::info!("server will start"); |
77 | 99 | ||