diff options
Diffstat (limited to 'crates/rust-analyzer/src/bin/logger.rs')
-rw-r--r-- | crates/rust-analyzer/src/bin/logger.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/bin/logger.rs b/crates/rust-analyzer/src/bin/logger.rs index 4ea4ffafb..3e5cc7acf 100644 --- a/crates/rust-analyzer/src/bin/logger.rs +++ b/crates/rust-analyzer/src/bin/logger.rs | |||
@@ -2,7 +2,10 @@ | |||
2 | //! filter syntax. Amusingly, there's no crates.io crate that can do this and | 2 | //! filter syntax. Amusingly, there's no crates.io crate that can do this and |
3 | //! only this. | 3 | //! only this. |
4 | 4 | ||
5 | use std::{borrow::BorrowMut, fs::File, io::{BufWriter, Write}}; | 5 | use std::{ |
6 | fs::File, | ||
7 | io::{self, BufWriter, Write}, | ||
8 | }; | ||
6 | 9 | ||
7 | use env_logger::filter::{Builder, Filter}; | 10 | use env_logger::filter::{Builder, Filter}; |
8 | use log::{Log, Metadata, Record}; | 11 | use log::{Log, Metadata, Record}; |
@@ -53,10 +56,6 @@ impl Log for Logger { | |||
53 | record.module_path().unwrap_or_default(), | 56 | record.module_path().unwrap_or_default(), |
54 | record.args(), | 57 | record.args(), |
55 | ); | 58 | ); |
56 | |||
57 | if self.no_buffering { | ||
58 | w.lock().borrow_mut().flush().unwrap(); | ||
59 | } | ||
60 | } | 59 | } |
61 | None => eprintln!( | 60 | None => eprintln!( |
62 | "[{} {}] {}", | 61 | "[{} {}] {}", |
@@ -65,11 +64,20 @@ impl Log for Logger { | |||
65 | record.args(), | 64 | record.args(), |
66 | ), | 65 | ), |
67 | } | 66 | } |
67 | |||
68 | if self.no_buffering { | ||
69 | self.flush(); | ||
70 | } | ||
68 | } | 71 | } |
69 | 72 | ||
70 | fn flush(&self) { | 73 | fn flush(&self) { |
71 | if let Some(w) = &self.file { | 74 | match &self.file { |
72 | let _ = w.lock().flush(); | 75 | Some(w) => { |
76 | let _ = w.lock().flush(); | ||
77 | } | ||
78 | None => { | ||
79 | let _ = io::stderr().flush(); | ||
80 | } | ||
73 | } | 81 | } |
74 | } | 82 | } |
75 | } | 83 | } |