color refactoring

This commit is contained in:
2020-11-03 17:57:03 +01:00
parent 6bbe4d7eaf
commit 747cbd3658
4 changed files with 66 additions and 25 deletions

View File

@ -106,4 +106,33 @@ int errMsg(const char *format, ...) {
return res;
}
int coloredMsg(const t_logColor color, const char *format, ...) {
const static char POST[] = "\x1b[0m\r\n";
const static char HIGH[] = "\x1b[1m";
const static char RED[] = "\x1b[31;1m";
const static char GREEN[] = "\x1b[32;1m";
const static char BLUE[] = "\x1b[34;1m";
const char *pre = NULL;
switch (color) {
case LOG_HIGH:
pre = HIGH;
break;
case LOG_RED:
pre = RED;
break;
case LOG_BLUE:
pre = BLUE;
break;
case LOG_GREEN:
pre = GREEN;
break;
}
va_list vl;
va_start(vl, format);
int res = innerLogMsg(pre, POST, format, vl);
va_end(vl);
return res;
}