67 const std::string
BOLD =
"\33[0;1m";
68 const std::string
GREY =
"\33[2;1m";
69 const std::string
ITALIC =
"\33[3;1m";
75 const std::string
RED =
"\33[31;1m";
76 const std::string
GREEN =
"\33[32;1m";
77 const std::string
YELLOW =
"\33[33;1m";
78 const std::string
BLUE =
"\33[34;1m";
79 const std::string
PINK =
"\33[35;1m";
121 std::ostream &stream = std::cout)
const {
132 inline int printMsg(
const std::vector<std::string> &msgs,
135 std::ostream &stream = std::cout)
const {
141 for(
auto &msg : msgs)
143 return prints == msgs.size() ? 1 : 0;
151 std::ostream &stream = std::cerr)
const {
161 std::ostream &stream = std::cerr)
const {
172 const double &progress,
175 const double &memory,
179 std::ostream &stream = std::cout)
const {
184 std::array<std::string, 4> chunks{};
188 chunks[q++] = std::to_string(
static_cast<int>(memory)) +
"MB";
190 std::stringstream sStream;
191 sStream.precision(3);
192 sStream << std::fixed;
194 chunks[q++] = sStream.str() +
"s";
197 chunks[q++] = std::to_string(threads) +
"T";
199 chunks[q++] = std::to_string((
int)(progress * 100)) +
"%";
201 std::string stats =
"";
205 for(
size_t i = 1; i < q; i++)
206 stats +=
"|" + chunks[i];
212 msg, stats, msg.length() < 1 ?
">" :
".", priority, lineMode, stream);
219 const double &progress,
224 std::ostream &stream = std::cout)
const {
226 msg, progress, time, -1, -1, lineMode, priority, stream);
234 const double &progress,
240 std::ostream &stream = std::cout)
const {
242 msg, progress, time, threads, -1, lineMode, priority, stream);
249 const double &progress,
253 std::ostream &stream = std::cout)
const {
255 msg, progress, -1, -1, -1, lineMode, priority, stream);
263 const double &progress,
266 std::ostream &stream = std::cout)
const {
267 return this->
printMsg(msg, progress, -1, -1, lineMode, priority, stream);
273 inline int printMsg(
const std::vector<std::vector<std::string>> &rows,
275 const bool hasHeader =
true,
277 std::ostream &stream = std::cout)
const {
282 const int nRows = rows.size();
283 const int nCols = nRows > 0 ? rows[0].size() : 0;
287 std::vector<std::string> formattedRows(nRows);
288 std::vector<size_t> colSizes(nCols, 0);
289 for(
int i = 0; i < nRows; i++)
290 for(
int j = 0; j < nCols; j++)
291 colSizes[j] = std::max(colSizes[j], rows[i][j].size());
293 auto formatCell = [](
const std::string &value,
const size_t &width,
294 const std::string &fillSymbol) {
295 std::string cell = value;
296 const int diff = width - cell.size();
297 for(
int i = 0; i < diff; i++)
304 for(
int i = 0; i < nRows; i++) {
305 auto &row = formattedRows[resultIndex++];
307 = formatCell(rows[i][0], colSizes[0],
" ") + (hasHeader ?
": " :
"");
309 row += formatCell(rows[i][1], colSizes[1],
" ");
310 for(
int j = 2; j < nCols; j++)
311 row +=
"," + formatCell(rows[i][j], colSizes[j],
" ");
314 return this->
printMsg(formattedRows, priority, lineMode, stream);
323 std::ostream &stream = std::cout)
const {
329 std::string(1, (
const char &)separator),
330 priority, lineMode, stream);
339 std::ostream &stream = std::cout)
const {
340 return this->
printMsg(separator, lineMode, priority, stream);
350 std::ostream &stream = std::cout)
const {
356 std::string(1, (
const char &)separator),
357 priority, lineMode, stream);
391 const std::string &right,
392 const std::string &filler,
395 std::ostream &stream = std::cout)
const {
397 std::string combinedMsg = msg;
399 if(filler.length() > 0) {
404 - combinedMsg.length() - right.length();
405 gapWidth = std::max(gapWidth / filler.length(), (
size_t)1);
407 for(
int i = 0; i < gapWidth; i++)
408 combinedMsg += filler;
422 std::ostream &stream = std::cout)
const {
424 if((this->debugLevel_ < (
int)priority)
438 if((
int)priority == 0)
441 else if((
int)priority == 1)
446 stream << msg.data();
457 this->lastLineMode = lineMode;
Legacy backward compatibility.
Legacy backward compatibility.
Minimalist debugging class.
int printMsg(const debug::Separator &separator, const debug::Priority &priority, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
int printMsgInternal(const std::string &msg, const std::string &right, const std::string &filler, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
int printWrn(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
int printMsg(const std::string &msg, const double &progress, const double &time, const int &threads, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
int printMsg(const std::vector< std::vector< std::string > > &rows, const debug::Priority &priority=debug::Priority::INFO, const bool hasHeader=true, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
int welcomeMsg(std::ostream &stream)
static COMMON_EXPORTS debug::LineMode lastLineMode
int printMsg(const std::string &msg, const double &progress, const double &time, const int &threads, const double &memory, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
int printMsg(const std::string &msg, const double &progress, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
int setWrapper(const Wrapper *wrapper) override
int printMsg(const std::string &msg, const debug::Separator &separator, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::INFO, std::ostream &stream=std::cout) const
std::string debugMsgNamePrefix_
void setDebugMsgPrefix(const std::string &prefix)
virtual int setDebugLevel(const int &debugLevel)
int printMsgInternal(const std::string &msg, const debug::Priority &priority, const debug::LineMode &lineMode, std::ostream &stream=std::cout) const
int printMsg(const std::string &msg, const double &progress, const debug::Priority &priority, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
std::string debugMsgPrefix_
int printMsg(const std::string &msg, const double &progress, const double &time, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::PERFORMANCE, std::ostream &stream=std::cout) const
int printMsg(const std::vector< std::string > &msgs, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
int printMsg(const debug::Separator &separator, const debug::LineMode &lineMode=debug::LineMode::NEW, const debug::Priority &priority=debug::Priority::INFO, std::ostream &stream=std::cout) const
int printMsg(const std::string &msg, const debug::Priority &priority=debug::Priority::INFO, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cout) const
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
Wrapper class to wrap ttk code.
const std::string ENDCOLOR
const std::string BRIGHTWHITE
const std::string INVERTED
const std::string FLASHING
const std::string LIGHTBLUE
const std::string DARKGREY
const std::string STRIKETHROUGH
const std::string UNDERLINED
COMMON_EXPORTS int MPIrank_
COMMON_EXPORTS bool goodbyeMsg_
COMMON_EXPORTS bool welcomeMsg_
COMMON_EXPORTS int globalDebugLevel_
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)