Parametrize the stream where the progress bar display goes
liori opened this issue · comments
Hi, it would be nice if one could set the stream that is used for displaying the progress bar. std::cout
can't always be used. For example, in applications whose stdout is then piped into something else it would be desirable to use std::cerr
for progress bars. In my case, Rcpp modules expect printing to be done through a special Rcpp::Rcout
object, as opposed to std::cout
.
Thank you!
This is already supported. Example.
You can pass a stream option to the constructor.
Hi, I came across this lib and would like to try it. However, I am currently writing the progress bar info using spdlog logging facilities, I was wondering if this lib supports setting custom handlers other than the mandatory "stream" option.
Something like this would be great:
auto logger = spdlog::default_logger;
ProgressBar bar{
option::BarWidth{50},
option::Start{"["},
option::Fill{"="},
option::Lead{">"},
option::Remainder{" "},
option::End{"]"},
option::PostfixText{"Getting started"},
option::ForegroundColor{indicators::Color::green},
option::FontStyles{std::vector<indicators::FontStyle>{indicators::FontStyle::bold}},
option::Handler{[&logger] (auto&& pbar_str) {logger.info("{}", pbar_str;)}};
where pbar_str
would be the rendered pbar content that get sent to the stream normally.