mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-26 09:42:00 -07:00
core: lock stdout before printing an error message to stderr
Adds a new eprintln_locked macro which locks STDOUT before logging to STDERR. This patch also replaces instances of eprintln with eprintln_locked to avoid interleaving lines. Fixes #1941, Closes #1968
This commit is contained in:
committed by
Andrew Gallant
parent
4993d29a16
commit
4782ebd5e0
@@ -33,7 +33,7 @@ impl Log for Logger {
|
||||
fn log(&self, record: &log::Record<'_>) {
|
||||
match (record.file(), record.line()) {
|
||||
(Some(file), Some(line)) => {
|
||||
eprintln!(
|
||||
eprintln_locked!(
|
||||
"{}|{}|{}:{}: {}",
|
||||
record.level(),
|
||||
record.target(),
|
||||
@@ -43,7 +43,7 @@ impl Log for Logger {
|
||||
);
|
||||
}
|
||||
(Some(file), None) => {
|
||||
eprintln!(
|
||||
eprintln_locked!(
|
||||
"{}|{}|{}: {}",
|
||||
record.level(),
|
||||
record.target(),
|
||||
@@ -52,7 +52,7 @@ impl Log for Logger {
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
eprintln!(
|
||||
eprintln_locked!(
|
||||
"{}|{}: {}",
|
||||
record.level(),
|
||||
record.target(),
|
||||
@@ -63,6 +63,6 @@ impl Log for Logger {
|
||||
}
|
||||
|
||||
fn flush(&self) {
|
||||
// We use eprintln! which is flushed on every call.
|
||||
// We use eprintln_locked! which is flushed on every call.
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user