mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-26 05:44:26 +00:00
make the logs line buffered
This commit is contained in:
parent
8b8eac5bf9
commit
799ec79f18
@ -48,7 +48,7 @@ impl Log for Logger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let should_flush = match &self.file {
|
match &self.file {
|
||||||
Some(w) => {
|
Some(w) => {
|
||||||
let _ = writeln!(
|
let _ = writeln!(
|
||||||
w.lock(),
|
w.lock(),
|
||||||
@ -57,22 +57,21 @@ impl Log for Logger {
|
|||||||
record.module_path().unwrap_or_default(),
|
record.module_path().unwrap_or_default(),
|
||||||
record.args(),
|
record.args(),
|
||||||
);
|
);
|
||||||
self.no_buffering
|
|
||||||
|
if self.no_buffering {
|
||||||
|
self.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
eprintln!(
|
let message = format!(
|
||||||
"[{} {}] {}",
|
"[{} {}] {}\n",
|
||||||
record.level(),
|
record.level(),
|
||||||
record.module_path().unwrap_or_default(),
|
record.module_path().unwrap_or_default(),
|
||||||
record.args(),
|
record.args(),
|
||||||
);
|
);
|
||||||
true // flush stderr unconditionally
|
eprint!("{}", message);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if should_flush {
|
|
||||||
self.flush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self) {
|
fn flush(&self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user