mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
Merge #9496
9496: fix: make the logs line buffered r=lnicola a=mahdi-frms fixes #9432 Not quite sure if that's what you want, but storing the log message in buffers eliminated the tiny write syscalls for me. I just changed the Logger struct. Co-authored-by: mahdi-frms <mahdif1380@outlook.com>
This commit is contained in:
commit
91bfa4b154
1 changed files with 10 additions and 10 deletions
|
@ -48,31 +48,31 @@ impl Log for Logger {
|
|||
return;
|
||||
}
|
||||
|
||||
let should_flush = match &self.file {
|
||||
match &self.file {
|
||||
Some(w) => {
|
||||
let mut writer = w.lock();
|
||||
let _ = writeln!(
|
||||
w.lock(),
|
||||
writer,
|
||||
"[{} {}] {}",
|
||||
record.level(),
|
||||
record.module_path().unwrap_or_default(),
|
||||
record.args(),
|
||||
);
|
||||
self.no_buffering
|
||||
|
||||
if self.no_buffering {
|
||||
let _ = writer.flush();
|
||||
}
|
||||
}
|
||||
None => {
|
||||
eprintln!(
|
||||
"[{} {}] {}",
|
||||
let message = format!(
|
||||
"[{} {}] {}\n",
|
||||
record.level(),
|
||||
record.module_path().unwrap_or_default(),
|
||||
record.args(),
|
||||
);
|
||||
true // flush stderr unconditionally
|
||||
eprint!("{}", message);
|
||||
}
|
||||
};
|
||||
|
||||
if should_flush {
|
||||
self.flush();
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {
|
||||
|
|
Loading…
Reference in a new issue