Add tracing to main rust-analyzer binary

This commit is contained in:
Florian Diebold 2020-10-23 17:07:06 +02:00 committed by Florian Diebold
parent 34034e4a64
commit 39dfca23f1
4 changed files with 29 additions and 1 deletions

3
Cargo.lock generated
View file

@ -1372,6 +1372,9 @@ dependencies = [
"text_edit", "text_edit",
"threadpool", "threadpool",
"toolchain", "toolchain",
"tracing",
"tracing-subscriber",
"tracing-tree",
"tt", "tt",
"vfs", "vfs",
"vfs-notify", "vfs-notify",

View file

@ -17,7 +17,7 @@ ena = "0.14.0"
log = "0.4.8" log = "0.4.8"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
scoped-tls = "1" scoped-tls = "1"
chalk-solve = "0.34" chalk-solve = { version = "0.34", default-features = false }
chalk-ir = "0.34" chalk-ir = "0.34"
chalk-recursive = "0.34" chalk-recursive = "0.34"

View file

@ -32,6 +32,9 @@ threadpool = "1.7.1"
rayon = "1.5" rayon = "1.5"
mimalloc = { version = "0.1.19", default-features = false, optional = true } mimalloc = { version = "0.1.19", default-features = false, optional = true }
lsp-server = "0.4.0" 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" } stdx = { path = "../stdx", version = "0.0.0" }
flycheck = { path = "../flycheck", version = "0.0.0" } flycheck = { path = "../flycheck", version = "0.0.0" }

View file

@ -68,10 +68,32 @@ fn setup_logging(log_file: Option<PathBuf>) -> Result<()> {
let filter = env::var("RA_LOG").ok(); let filter = env::var("RA_LOG").ok();
logger::Logger::new(log_file, filter.as_deref()).install(); logger::Logger::new(log_file, filter.as_deref()).install();
tracing_setup::setup_tracing()?;
profile::init(); profile::init();
Ok(()) 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<()> { fn run_server() -> Result<()> {
log::info!("server will start"); log::info!("server will start");