summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/logs.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/core/logs.c b/src/core/logs.c
index 8327203..aedc78e 100644
--- a/src/core/logs.c
+++ b/src/core/logs.c
@@ -25,8 +25,10 @@
#include <malloc.h>
+#include <string.h>
+#include "../common/extstr.h"
#include "../gui/core/panels.h"
#include "../gui/panels/log.h"
@@ -186,6 +188,51 @@ void log_variadic_message(LogMessageType type, const char *fmt, ...)
static void print_message_without_gui(LogMessageType type, const char *msg)
{
- printf("!! MSG :: %s\n", msg);
+ char *formatted; /* Copie formatée du message */
+ const char *prefix; /* Introduction de la ligne */
+
+ formatted = strdup(msg);
+
+#define FOREGROUND_LIGHT_GRAY "\e[37m"
+#define FOREGROUND_RED "\e[91m"
+
+#define BACKGROUND_RED "\e[101m"
+
+#define BOLD "\e[1m"
+#define ITALIC "\e[3m"
+
+#define RESET "\e[0m"
+
+ switch (type)
+ {
+ case LMT_INFO:
+ default:
+ prefix = "i";
+ break;
+
+ case LMT_PROCESS:
+ prefix = FOREGROUND_LIGHT_GRAY "*" RESET;
+ break;
+
+ case LMT_WARNING:
+ prefix = FOREGROUND_RED "!" RESET;
+ break;
+
+ case LMT_ERROR:
+ case LMT_BAD_BINARY:
+ prefix = BACKGROUND_RED "!" RESET;
+ break;
+
+ }
+
+ formatted = strrpl(formatted, "<b>", BOLD);
+ formatted = strrpl(formatted, "</b>", RESET);
+
+ formatted = strrpl(formatted, "<i>", ITALIC);
+ formatted = strrpl(formatted, "</i>", RESET);
+
+ printf("[%s] %s\n", prefix, formatted);
+
+ free(formatted);
}