From: Mazet Laurent Date: Thu, 27 Mar 2025 13:03:50 +0000 (+0100) Subject: color logs X-Git-Tag: v1.0~101 X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=71ab2721d78e74fba482d6a706b36a9cae5aafae;p=morep.git color logs --- diff --git a/makefile b/makefile index 7db77be..d9f3225 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ CC = gcc #INCLUDES = -I../debug -D__MEMORY_ALLOCATION__ -INCLUDES = +INCLUDES += -DVERBOSE_COLOR=1 OFLAGS = -O4 -Os #OFLAGS = -O0 #OFLAGS = -O4 -ffast-math -finline-functions diff --git a/verbose.h b/verbose.h index 539f085..2965ef3 100644 --- a/verbose.h +++ b/verbose.h @@ -20,6 +20,10 @@ __BEGIN_DECLS +#ifndef VERBOSE_COLOR +#define VERBOSE_COLOR 0 +#endif + /** Debug level - Error messages @@ -69,7 +73,18 @@ __BEGIN_DECLS extern int verbose_##module; \ if (level > verbose_##module) \ break; \ + if (VERBOSE_COLOR) { \ + if (level == ERROR) \ + printf ("\e[1;31m"); \ + else if (level == WARNING) \ + printf ("\e[1;33m"); \ + else if (level == DEBUG) \ + printf ("\e[1;32m"); \ + else if (level == TRACE) \ + printf ("\e[1;34m"); \ + } \ statement; \ + printf ("\e[0;0m"); \ } while(0) /** @@ -80,7 +95,7 @@ __BEGIN_DECLS */ #define PRINTF(format...) \ do { \ - printf ("%s[%d]: ", __FILE__, __LINE__); \ + printf ("%s+%d: ", __FILE__, __LINE__); \ printf (format); \ fflush (stdout); \ } while (0)