Skip to content

Commit 799ec79

Browse files
committed
make the logs line buffered
1 parent 8b8eac5 commit 799ec79

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

crates/rust-analyzer/src/bin/logger.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Log for Logger {
4848
return;
4949
}
5050

51-
let should_flush = match &self.file {
51+
match &self.file {
5252
Some(w) => {
5353
let _ = writeln!(
5454
w.lock(),
@@ -57,22 +57,21 @@ impl Log for Logger {
5757
record.module_path().unwrap_or_default(),
5858
record.args(),
5959
);
60-
self.no_buffering
60+
61+
if self.no_buffering {
62+
self.flush();
63+
}
6164
}
6265
None => {
63-
eprintln!(
64-
"[{} {}] {}",
66+
let message = format!(
67+
"[{} {}] {}\n",
6568
record.level(),
6669
record.module_path().unwrap_or_default(),
6770
record.args(),
6871
);
69-
true // flush stderr unconditionally
72+
eprint!("{}", message);
7073
}
7174
};
72-
73-
if should_flush {
74-
self.flush();
75-
}
7675
}
7776

7877
fn flush(&self) {

0 commit comments

Comments
 (0)