20#include "inja/inja.hpp"
34 progress_bars_.set_option(indicators::option::HideBarWhenComplete{
false});
38 const std::string &name,
size_t max, indicators::Color )
41 j[
"diagram_name"] = name;
44 j[
"status"] =
"started";
52 spdlog::get(
"json-progress-logger")
53 ->log(spdlog::level::info,
"{}", j.dump());
57 const std::string &name,
size_t max, indicators::Color color)
59 auto postfix_text = max > 0 ? fmt::format(
"{}/{}", 0, max) : std::string{};
61 const auto kBarWidth = 35U;
62 const auto kPrefixTextWidth = 25U;
64 auto bar = std::make_shared<indicators::ProgressBar>(
65 indicators::option::Stream{
ostream_},
66 indicators::option::BarWidth{kBarWidth},
67 indicators::option::ForegroundColor{color},
68 indicators::option::ShowElapsedTime{
true},
70 indicators::option::Fill{
"="}, indicators::option::Lead{
">"},
72 indicators::option::Fill{
"█"}, indicators::option::Lead{
"█"},
74 indicators::option::Remainder{
"-"},
75 indicators::option::PrefixText{
77 indicators::option::PostfixText{postfix_text});
83 auto bar_index =
bars_.size() - 1;
92 j[
"diagram_name"] = name;
103 j[
"progress"] = p.progress;
105 j[
"status"] =
"ongoing";
111 spdlog::get(
"json-progress-logger")
112 ->log(spdlog::level::info,
"{}", j.dump());
117 const auto kASTTraverseProgressPercent = 95U;
131 bar.set_progress((p.progress * kASTTraverseProgressPercent) / p.max);
132 bar.set_option(indicators::option::PostfixText{
133 fmt::format(
"{}/{}", p.progress, p.max)});
152 j[
"diagram_name"] = name;
165 j[
"progress"] = p.progress;
167 j[
"status"] =
"completed";
171 spdlog::get(
"json-progress-logger")
172 ->log(spdlog::level::info,
"{}", j.dump());
177 const auto kCompleteProgressPercent = 100U;
191 bar.set_progress(kCompleteProgressPercent);
194 const auto postfix_text = fmt::format(
"{}/{} OK", p.progress, p.max);
196 const auto postfix_text = fmt::format(
"{}/{} ✔", p.progress, p.max);
198 bar.set_option(indicators::option::PostfixText{postfix_text});
200 indicators::option::ForegroundColor{indicators::Color::green});
201 bar.mark_as_completed();
209 j[
"diagram_name"] = name;
219 j[
"progress"] = p.progress;
221 j[
"status"] =
"failed";
225 spdlog::get(
"json-progress-logger")
226 ->log(spdlog::level::err,
"{}", j.dump());
242 const auto postfix_text = fmt::format(
"{}/{} FAILED", p.progress, p.max);
244 const auto postfix_text = fmt::format(
"{}/{} ✗", p.progress, p.max);
246 bar.set_option(indicators::option::ForegroundColor{indicators::Color::red});
247 bar.set_option(indicators::option::PostfixText{postfix_text});
248 bar.mark_as_completed();