summaryrefslogtreecommitdiff
path: root/cli/cache/cache_db.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-05-30 13:35:02 -0400
committerGitHub <noreply@github.com>2023-05-30 13:35:02 -0400
commit42a3f52e983e6b37ac1f69733a9347505e061e43 (patch)
tree51c047633f00c911b3f6d463402a0fccd60668b5 /cli/cache/cache_db.rs
parent3b69d238cdedc7f47515ba74f2366724679c5c7d (diff)
fix: do not show cache initialization errors if stderr is piped (#18920)
Closes #18918
Diffstat (limited to 'cli/cache/cache_db.rs')
-rw-r--r--cli/cache/cache_db.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/cli/cache/cache_db.rs b/cli/cache/cache_db.rs
index fd694062c..cdab27f4c 100644
--- a/cli/cache/cache_db.rs
+++ b/cli/cache/cache_db.rs
@@ -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()
);