diff options
-rw-r--r-- | plugins/devdbg/speed.c | 2 | ||||
-rw-r--r-- | src/core/logs.c | 49 |
2 files changed, 49 insertions, 2 deletions
diff --git a/plugins/devdbg/speed.c b/plugins/devdbg/speed.c index 9cb7d45..f967e43 100644 --- a/plugins/devdbg/speed.c +++ b/plugins/devdbg/speed.c @@ -98,7 +98,7 @@ G_MODULE_EXPORT void process_binary_disassembly(const GPluginModule *plugin, Plu take_measure(&measure->points[1], &measure->usages[1]); #define SHOW_SPEED(pg, sm, title, p0, p1) \ - g_plugin_module_log_variadic_message(pg, LMT_INFO, title " : %.2g (%.2g)", \ + g_plugin_module_log_variadic_message(pg, LMT_INFO, title ": %.2g (%.2g)", \ (double)(sm->points[p1] - sm->points[p0]) / CLOCKS_PER_SEC, \ (sm->usages[p1] - sm->usages[p0]) / 1000000.0); 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); } |