aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-14 21:04:08 +0100
committerAleksey Kladov <[email protected]>2019-04-14 23:10:07 +0100
commitb228947b6863f5864b48bb3a7f3dcca921f58d0b (patch)
tree208d849b755a91e2f3640c1550ca8c74192a579a /crates/ra_lsp_server
parente6f32c6d3a5626a1f071d96d2cdebe630abdd5a3 (diff)
cleanup syntax
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r--crates/ra_lsp_server/src/main.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/main.rs b/crates/ra_lsp_server/src/main.rs
index 4646742ca..28f9985b6 100644
--- a/crates/ra_lsp_server/src/main.rs
+++ b/crates/ra_lsp_server/src/main.rs
@@ -12,15 +12,27 @@ fn main() -> Result<()> {
12 Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?, 12 Ok(ref v) if v == "1" => logger.log_to_file().directory("log").start()?,
13 _ => logger.start()?, 13 _ => logger.start()?,
14 }; 14 };
15 let prof_depth = match std::env::var("RA_PROFILE_DEPTH") { 15 // Filtering syntax
16 Ok(ref d) => d.parse()?, 16 // env RA_PROFILE=* // dump everything
17 _ => 0, 17 // env RA_PROFILE=foo|bar|baz // enabled only selected entries
18 }; 18 // env RA_PROFILE=*@3 // dump everything, up to depth 3
19 let profile_allowed = match std::env::var("RA_PROFILE") { 19 let filter = match std::env::var("RA_PROFILE") {
20 Ok(ref p) => p.split(";").map(String::from).collect(), 20 Ok(p) => {
21 _ => Vec::new(), 21 let mut p = p.as_str();
22 let depth = if let Some(idx) = p.rfind("@") {
23 let depth: usize = p[idx + 1..].parse().expect("invalid profile depth");
24 p = &p[..idx];
25 depth
26 } else {
27 999
28 };
29 let allowed =
30 if p == "*" { Vec::new() } else { p.split(";").map(String::from).collect() };
31 ra_prof::Filter::new(depth, allowed)
32 }
33 Err(_) => ra_prof::Filter::disabled(),
22 }; 34 };
23 ra_prof::set_filter(ra_prof::Filter::new(prof_depth, profile_allowed)); 35 ra_prof::set_filter(filter);
24 log::info!("lifecycle: server started"); 36 log::info!("lifecycle: server started");
25 match ::std::panic::catch_unwind(main_inner) { 37 match ::std::panic::catch_unwind(main_inner) {
26 Ok(res) => { 38 Ok(res) => {