fix: do not show cache initialization errors if stderr is piped (#18920)

Closes #18918
This commit is contained in:
David Sherret 2023-05-30 13:35:02 -04:00 committed by GitHub
parent 3b69d238cd
commit 42a3f52e98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

18
cli/cache/cache_db.rs vendored
View file

@ -261,7 +261,9 @@ impl CacheDB {
};
// Failed, try deleting it
log::warn!(
let is_tty = atty::is(atty::Stream::Stderr);
log::log!(
if is_tty { log::Level::Warn } else { log::Level::Trace },
"Could not initialize cache database '{}', deleting and retrying... ({err:?})",
path.to_string_lossy()
);
@ -275,7 +277,12 @@ impl CacheDB {
match self.config.on_failure {
CacheFailure::InMemory => {
log::error!(
log::log!(
if is_tty {
log::Level::Error
} else {
log::Level::Trace
},
"Failed to open cache file '{}', opening in-memory cache.",
path.to_string_lossy()
);
@ -284,7 +291,12 @@ impl CacheDB {
))
}
CacheFailure::Blackhole => {
log::error!(
log::log!(
if is_tty {
log::Level::Error
} else {
log::Level::Trace
},
"Failed to open cache file '{}', performance may be degraded.",
path.to_string_lossy()
);