color refactoring
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user