diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-04-16 13:12:58 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-04-16 18:03:38 +0200 |
commit | 67a5941472ab56a798556ee2d5afc62fc38a799a (patch) | |
tree | c96092cfc32ebb4355f99f7d678810a5a4ff3276 /src/nix/progress-bar.cc | |
parent | fcd048a526bd239fa615457e77d61d69d679bf03 (diff) |
Logger: Add method for writing to stdout
Usually this just writes to stdout, but for ProgressBar, we need to
clear the current line, write the line to stdout, and then redraw the
progress bar.
(cherry picked from commit 696c026006a6ac46adc990ed5cb0f31535bac076)
Diffstat (limited to 'src/nix/progress-bar.cc')
-rw-r--r-- | src/nix/progress-bar.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nix/progress-bar.cc b/src/nix/progress-bar.cc index adc9b9a5d..8e7ba95a3 100644 --- a/src/nix/progress-bar.cc +++ b/src/nix/progress-bar.cc @@ -7,6 +7,7 @@ #include <atomic> #include <map> #include <thread> +#include <iostream> namespace nix { @@ -442,6 +443,18 @@ public: return res; } + + void writeToStdout(std::string_view s) override + { + auto state(state_.lock()); + if (state->active) { + std::cerr << "\r\e[K"; + Logger::writeToStdout(s); + draw(*state); + } else { + Logger::writeToStdout(s); + } + } }; void startProgressBar(bool printBuildLogs) |