#include #include #define _LOG_COLORS #include "logger.h" #include "loc.h" void mcl_log(log_level_t level, const char *fmt, ...) { va_list args; va_start(args, fmt); char* prefix; switch (level) { case ERROR: prefix = BRIGHT FG_RED "ERROR" RESET; break; case WARN: prefix = BRIGHT FG_YELLOW "WARN" RESET; break; case HELP: prefix = BRIGHT FG_CYAN "HELP" RESET; break; case INFO: prefix = BRIGHT FG_GREEN "INFO" RESET; break; case DEBUG: prefix = BRIGHT FG_BLUE "DEBUG" RESET; break; } printf("%s: ", prefix); vprintf(fmt, args); puts(""); va_end(args); } void mcl_log_loc(log_level_t level, loc_t* loc, const char *fmt, ...) { va_list args; va_start(args, fmt); char* prefix; switch (level) { case ERROR: prefix = BRIGHT FG_RED "ERROR" RESET; break; case WARN: prefix = BRIGHT FG_YELLOW "WARN" RESET; break; case HELP: prefix = BRIGHT FG_CYAN "HELP" RESET; break; case INFO: prefix = BRIGHT FG_GREEN "INFO" RESET; break; case DEBUG: prefix = BRIGHT FG_BLUE "DEBUG" RESET; break; } printf(BRIGHT"%s"RESET":"BRIGHT"%zu"RESET":"BRIGHT"%zu"RESET": ", loc->file, loc->line, loc->col); printf("%s: ", prefix); vprintf(fmt, args); puts(""); va_end(args); }