diff options
author | vsrs <[email protected]> | 2021-01-26 21:59:31 +0000 |
---|---|---|
committer | vsrs <[email protected]> | 2021-01-26 22:16:39 +0000 |
commit | 5f1eb544da9f33f3402914ba5c4318032cbad0c3 (patch) | |
tree | 65e6fa4a8b4f5b39d271448a39d3557b249a6c12 | |
parent | 0269071283cd8d090c00f2bc1d84b4fabbe9ea87 (diff) |
Apply suggestions.
-rw-r--r-- | crates/rust-analyzer/src/bin/args.rs | 5 | ||||
-rw-r--r-- | crates/rust-analyzer/src/bin/logger.rs | 23 |
2 files changed, 17 insertions, 11 deletions
diff --git a/crates/rust-analyzer/src/bin/args.rs b/crates/rust-analyzer/src/bin/args.rs index 100e46d2f..37d8414f4 100644 --- a/crates/rust-analyzer/src/bin/args.rs +++ b/crates/rust-analyzer/src/bin/args.rs | |||
@@ -50,7 +50,8 @@ FLAGS: | |||
50 | -q, --quiet Set verbosity | 50 | -q, --quiet Set verbosity |
51 | 51 | ||
52 | --log-file <PATH> Log to the specified file instead of stderr | 52 | --log-file <PATH> Log to the specified file instead of stderr |
53 | --no-buffering Flush log records to the file immediately | 53 | --no-log-buffering |
54 | Flush log records to the file immediately | ||
54 | 55 | ||
55 | --wait-dbg Wait until a debugger is attached to. | 56 | --wait-dbg Wait until a debugger is attached to. |
56 | The flag is valid for debug builds only | 57 | The flag is valid for debug builds only |
@@ -139,7 +140,7 @@ impl Args { | |||
139 | (false, true, true) => bail!("Invalid flags: -q conflicts with -v"), | 140 | (false, true, true) => bail!("Invalid flags: -q conflicts with -v"), |
140 | }; | 141 | }; |
141 | let log_file = matches.opt_value_from_str("--log-file")?; | 142 | let log_file = matches.opt_value_from_str("--log-file")?; |
142 | let no_buffering = matches.contains("--no-buffering"); | 143 | let no_buffering = matches.contains("--no-log-buffering"); |
143 | let wait_dbg = matches.contains("--wait-dbg"); | 144 | let wait_dbg = matches.contains("--wait-dbg"); |
144 | 145 | ||
145 | if matches.contains(["-h", "--help"]) { | 146 | if matches.contains(["-h", "--help"]) { |
diff --git a/crates/rust-analyzer/src/bin/logger.rs b/crates/rust-analyzer/src/bin/logger.rs index 3e5cc7acf..14887c5cc 100644 --- a/crates/rust-analyzer/src/bin/logger.rs +++ b/crates/rust-analyzer/src/bin/logger.rs | |||
@@ -47,7 +47,8 @@ impl Log for Logger { | |||
47 | if !self.filter.matches(record) { | 47 | if !self.filter.matches(record) { |
48 | return; | 48 | return; |
49 | } | 49 | } |
50 | match &self.file { | 50 | |
51 | let should_flush = match &self.file { | ||
51 | Some(w) => { | 52 | Some(w) => { |
52 | let _ = writeln!( | 53 | let _ = writeln!( |
53 | w.lock(), | 54 | w.lock(), |
@@ -56,16 +57,20 @@ impl Log for Logger { | |||
56 | record.module_path().unwrap_or_default(), | 57 | record.module_path().unwrap_or_default(), |
57 | record.args(), | 58 | record.args(), |
58 | ); | 59 | ); |
60 | self.no_buffering | ||
59 | } | 61 | } |
60 | None => eprintln!( | 62 | None => { |
61 | "[{} {}] {}", | 63 | eprintln!( |
62 | record.level(), | 64 | "[{} {}] {}", |
63 | record.module_path().unwrap_or_default(), | 65 | record.level(), |
64 | record.args(), | 66 | record.module_path().unwrap_or_default(), |
65 | ), | 67 | record.args(), |
66 | } | 68 | ); |
69 | true // flush stderr unconditionally | ||
70 | } | ||
71 | }; | ||
67 | 72 | ||
68 | if self.no_buffering { | 73 | if should_flush { |
69 | self.flush(); | 74 | self.flush(); |
70 | } | 75 | } |
71 | } | 76 | } |