metrics: Only print IBD progress bar on TTY

Now that it is created from space characters, it is meaningless to print
it to a log file.
This commit is contained in:
Jack Grigg 2020-06-02 14:23:03 +12:00
parent a79337c3ee
commit 12e169d09f
1 changed files with 20 additions and 18 deletions

View File

@ -266,7 +266,7 @@ boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params,
} }
} }
int printStats(bool mining) int printStats(bool isScreen, bool mining)
{ {
// Number of lines that are always displayed // Number of lines that are always displayed
int lines = 5; int lines = 5;
@ -304,6 +304,7 @@ int printStats(bool mining)
int downloadPercent = height * 100 / netheight; int downloadPercent = height * 100 / netheight;
std::cout << " " << _("Downloading blocks") << " | " << height << " (" << nHeaders << " " << _("headers") << ") / ~" << netheight << " (" << downloadPercent << "%)" << std::endl; std::cout << " " << _("Downloading blocks") << " | " << height << " (" << nHeaders << " " << _("headers") << ") / ~" << netheight << " (" << downloadPercent << "%)" << std::endl;
if (isScreen) {
// Draw 50-character progress bar, which will fit into a 79-character line. // Draw 50-character progress bar, which will fit into a 79-character line.
int blockChars = downloadPercent / 2; int blockChars = downloadPercent / 2;
int headerChars = (nHeaders * 50) / netheight; int headerChars = (nHeaders * 50) / netheight;
@ -323,6 +324,7 @@ int printStats(bool mining)
std::cout << "]" << std::endl; std::cout << "]" << std::endl;
lines++; lines++;
} }
}
} else { } else {
std::cout << " " << _("Block height") << " | " << height << std::endl; std::cout << " " << _("Block height") << " | " << height << std::endl;
} }
@ -604,7 +606,7 @@ void ThreadShowMetricsScreen()
#endif #endif
if (loaded) { if (loaded) {
lines += printStats(mining); lines += printStats(isScreen, mining);
lines += printMiningStatus(mining); lines += printMiningStatus(mining);
} }
lines += printMetrics(cols, mining); lines += printMetrics(cols, mining);