summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/log.c15
-rw-r--r--src/utils/log.h5
2 files changed, 13 insertions, 7 deletions
diff --git a/src/utils/log.c b/src/utils/log.c
index 3f73729..9b8f94f 100644
--- a/src/utils/log.c
+++ b/src/utils/log.c
@@ -17,8 +17,8 @@ void _printLogBack(const char *format, const char *file, int line, ...) {
free(errorStr);
}
-void _printErrorBack(const char *file, int line, char *begin, char *end,
- const char *format, ...) {
+void _printErrorWarningBack(const char *file, int line, char *begin, char *end,
+ bool isError, const char *format, ...) {
va_list args;
va_start(args, end);
char *errorStr;
@@ -35,9 +35,14 @@ void _printErrorBack(const char *file, int line, char *begin, char *end,
}
const char firstColor[] = "\e[0;36m";
- const char secondColor[] = "\e[0;31m";
- fprintf(stderr, "%sError: %s at compiler %s:%d\e[0m\n", firstColor, errorStr,
- file, line);
+ const char *secondColor = isError ? "\e[0;31m" : "\e[0;33m";
+ if (isError) {
+ fprintf(stderr, "%sError: %s at compiler %s:%d\e[0m\n", firstColor,
+ errorStr, file, line);
+ } else {
+ fprintf(stderr, "%sWarning: %s at compiler %s:%d\e[0m\n", firstColor,
+ errorStr, file, line);
+ }
free(errorStr);
if (file_index == SIZE_MAX) {
diff --git a/src/utils/log.h b/src/utils/log.h
index 6cede24..a0d48a6 100644
--- a/src/utils/log.h
+++ b/src/utils/log.h
@@ -1,10 +1,11 @@
#pragma once
#define printLog(format,...) _printLogBack(format, __FILE_NAME__, __LINE__, ## __VA_ARGS__)
-#define printError(begin,end,format,...) _printErrorBack(__FILE_NAME__, __LINE__, begin, end, format, ## __VA_ARGS__)
+#define printError(begin,end,format,...) _printErrorWarningBack(__FILE_NAME__, __LINE__, begin, end, true, format, ## __VA_ARGS__)
+#define printWarning(begin,end,format,...) _printErrorWarningBack(__FILE_NAME__, __LINE__, begin, end, false, format, ## __VA_ARGS__)
#define UNREACHABLE printLog("Unreachable");exit(1)
extern void _printLogBack(const char *format, const char *file, int line, ...);
-extern void _printErrorBack(const char *file, int line, char *begin, char *end,const char *format, ...);
+extern void _printErrorWarningBack(const char *file, int line, char *begin, char *end,bool isError,const char *format, ...);