diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/main.rs | 28 |
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) => { |