Quellcode durchsuchen

Extend terminal coloring

Kajetan Johannes Hammerle vor 2 Monaten
Ursprung
Commit
921a0d44ad
2 geänderte Dateien mit 23 neuen und 11 gelöschten Zeilen
  1. 23 10
      include/core/Logger.h
  2. 0 1
      test/Main.c

+ 23 - 10
include/core/Logger.h

@@ -3,10 +3,23 @@
 
 #include "core/Check.h"
 
-#define TERMINAL_RED "\33[1;31m"
-#define TERMINAL_YELLOW "\33[1;33m"
-#define TERMINAL_GRAY "\33[1;37m"
-#define TERMINAL_GREEN "\33[1;32m"
+#define TERMINAL_BOLD "\33[1m"
+#define TERMINAL_BLACK "\33[30m"
+#define TERMINAL_RED "\33[31m"
+#define TERMINAL_GREEN "\33[32m"
+#define TERMINAL_YELLOW "\33[33m"
+#define TERMINAL_BLUE "\33[34m"
+#define TERMINAL_MAGENTA "\33[35m"
+#define TERMINAL_CYAN "\33[36m"
+#define TERMINAL_WHITE "\33[37m"
+#define TERMINAL_BRIGHT_BLACK "\33[90m"
+#define TERMINAL_BRIGHT_RED "\33[91m"
+#define TERMINAL_BRIGHT_GREEN "\33[92m"
+#define TERMINAL_BRIGHT_YELLOW "\33[93m"
+#define TERMINAL_BRIGHT_BLUE "\33[94m"
+#define TERMINAL_BRIGHT_MAGENTA "\33[95m"
+#define TERMINAL_BRIGHT_CYAN "\33[96m"
+#define TERMINAL_BRIGHT_WHITE "\33[97m"
 #define TERMINAL_RESET "\33[0m"
 
 typedef enum { LOG_NONE, LOG_ERROR, LOG_WARNING, LOG_INFO, LOG_DEBUG } LogLevel;
@@ -21,7 +34,7 @@ check_format(6, 7) void printLog(LogLevel l, const char* file, int line,
 
 #if defined(LOG_LEVEL) && LOG_LEVEL >= 1
 #define LOG_ERROR(...)                                                         \
-    printLog(LOG_ERROR, __FILE__, __LINE__, TERMINAL_RED, "[ERROR] ",          \
+    printLog(LOG_ERROR, __FILE__, __LINE__, TERMINAL_BRIGHT_RED, "[ERROR] ",   \
              __VA_ARGS__)
 #else
 #define LOG_ERROR(...)
@@ -29,15 +42,15 @@ check_format(6, 7) void printLog(LogLevel l, const char* file, int line,
 
 #if defined(LOG_LEVEL) && LOG_LEVEL >= 2
 #define LOG_WARNING(...)                                                       \
-    printLog(LOG_WARNING, __FILE__, __LINE__, TERMINAL_YELLOW, "[WARNING] ",   \
-             __VA_ARGS__)
+    printLog(LOG_WARNING, __FILE__, __LINE__, TERMINAL_BRIGHT_YELLOW,          \
+             "[WARNING] ", __VA_ARGS__)
 #else
 #define LOG_WARNING(...)
 #endif
 
 #if defined(LOG_LEVEL) && LOG_LEVEL >= 3
 #define LOG_INFO(...)                                                          \
-    printLog(LOG_INFO, __FILE__, __LINE__, TERMINAL_GRAY, "[INFO] ",           \
+    printLog(LOG_INFO, __FILE__, __LINE__, TERMINAL_BOLD, "[INFO] ",           \
              __VA_ARGS__)
 #else
 #define LOG_INFO(...)
@@ -45,8 +58,8 @@ check_format(6, 7) void printLog(LogLevel l, const char* file, int line,
 
 #if defined(LOG_LEVEL) && LOG_LEVEL >= 4
 #define LOG_DEBUG(...)                                                         \
-    printLog(LOG_DEBUG, __FILE__, __LINE__, TERMINAL_GREEN, "[DEBUG] ",        \
-             __VA_ARGS__)
+    printLog(LOG_DEBUG, __FILE__, __LINE__,                                    \
+             TERMINAL_BOLD TERMINAL_BRIGHT_BLACK, "[DEBUG] ", __VA_ARGS__)
 #else
 #define LOG_DEBUG(...)
 #endif

+ 0 - 1
test/Main.c

@@ -1,5 +1,4 @@
 #include <locale.h>
-#include <stdio.h>
 #include <string.h>
 
 #include "Tests.h"