add a compilation flag to remove file location on verbose messages
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 8 Apr 2025 22:58:35 +0000 (00:58 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Tue, 8 Apr 2025 23:05:43 +0000 (01:05 +0200)
makefile
verbose.h

index b9784bf554d479e4bbeafd18d5025304627c8706..02337374ac87b0cf259d30ab3f5c8efce61373ce 100644 (file)
--- a/makefile
+++ b/makefile
@@ -4,6 +4,7 @@ CC = gcc
 
 #INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
 INCLUDES += -DVERBOSE_COLOR=1
+#INCLUDES += -DVERBOSE_LOCATION=1
 OFLAGS  = -O4 -Os
 #OFLAGS  = -O0
 #OFLAGS  = -O4 -ffast-math -finline-functions
index 3eddc9464963f549e48c8be5731643326b2a749f..09daadfcfd64dc997fd41e8b2b94c13f440bf3ca 100644 (file)
--- a/verbose.h
+++ b/verbose.h
@@ -23,6 +23,9 @@ __BEGIN_DECLS
 #ifndef VERBOSE_COLOR
 #define VERBOSE_COLOR 0
 #endif
+#ifndef VERBOSE_LOCATION
+#define VERBOSE_LOCATION 0
+#endif
 
 /**
    Debug level
@@ -99,11 +102,12 @@ __BEGIN_DECLS
    @param format format string
    @param ... optionnal arguments
 */
-#define PRINTF(format...)                                   \
-    do {                                                    \
-        printf ("%s+%d[%s]: ", __FILE__, __LINE__, _level); \
-        printf (format);                                    \
-        fflush (stdout);                                    \
+#define PRINTF(format...)                                            \
+    do {                                                             \
+        if (VERBOSE_LOCATION) printf ("%s+%d ", __FILE__, __LINE__); \
+        printf ("[%s] ", _level);                                    \
+        printf (format);                                             \
+        fflush (stdout);                                             \
     } while (0)
 
 
@@ -114,11 +118,12 @@ __BEGIN_DECLS
    @param format format string
    @param ... optionnal arguments
 */
-#define FPRINTF(stream, format...)                                  \
-    do {                                                            \
-        fprintf (stream,"%s+%d[%s]: ", __FILE__, __LINE__, _level); \
-        fprintf (stream, format);                                   \
-        fflush (stream);                                            \
+#define FPRINTF(stream, format...)                                            \
+    do {                                                                      \
+        if (VERBOSE_LOCATION) fprintf (stream, "%s+%d ", __FILE__, __LINE__); \
+        fprintf (stream, "[%s] ", _level);                                    \
+        fprintf (stream, format);                                             \
+        fflush (stream);                                                      \
     } while (0)
 
 __END_DECLS