Changeset: 645fed5d4a7e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=645fed5d4a7e
Modified Files:
        gdk/gdk_tracer.c
        gdk/gdk_tracer.h
Branch: gdk-tracer
Log Message:

CRITICAL, ERROR and WARNING messages are logged mo natter the component


diffs (107 lines):

diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -29,6 +29,9 @@
 #include "gdk.h"
 #include "gdk_tracer.h"
 
+/* CHECK */
+// Make CUR_FLUSH_LEVEL => ATOMIC_TYPE?
+
 // 0 -> tracer
 // 1 -> secondary_tracer
 static gdk_tracer tracer = { .allocated_size = 0, .id = 0, .lock = 
MT_LOCK_INITIALIZER("GDKtracerL") };
@@ -39,12 +42,9 @@ static bool GDK_TRACER_STOP = false;
 
 static FILE *output_file;
 static ATOMIC_TYPE CUR_ADAPTER = DEFAULT_ADAPTER;
+static LOG_LEVEL CUR_FLUSH_LEVEL = DEFAULT_FLUSH_LEVEL;
+LOG_LEVEL CUR_LOG_LEVEL = DEFAULT_LOG_LEVEL;
 
-/* CHECK */
-// Should it be ATOMIC_TYPE?
-static LOG_LEVEL CUR_FLUSH_LEVEL = DEFAULT_FLUSH_LEVEL;
-// We need it as a global - else create a wrapper function that returns it
-LOG_LEVEL CUR_LOG_LEVEL = DEFAULT_LOG_LEVEL;
 
 // Output error from snprintf of vsnprintf
 static void 
@@ -79,7 +79,6 @@ static void
 }
 
 
-
 // Candidate for 'gnu_printf' format attribute 
[-Werror=suggest-attribute=format]
 static int 
 _GDKtracer_fill_tracer(gdk_tracer *sel_tracer, const char *fmt, va_list va) 
__attribute__ ((format (printf, 2, 0)));
diff --git a/gdk/gdk_tracer.h b/gdk/gdk_tracer.h
--- a/gdk/gdk_tracer.h
+++ b/gdk/gdk_tracer.h
@@ -166,35 +166,42 @@ extern LOG_LEVEL CUR_LOG_LEVEL;
  * Function name is detected automatically
  * 
  */
-#define GDK_TRACER_LOG(LOG_LEVEL, COMP, MSG, ...)                       \
-    if(CUR_LOG_LEVEL >= LOG_LEVEL)                                      \
-    {                                                                   \
-        GDKtracer_log(LOG_LEVEL,                                        \
-                      "[%s] %s <%s:%d> (%s - %s) %s # "MSG,             \
-                      GDKtracer_get_timestamp("%Y-%m-%d %H:%M:%S"),     \
-                      __FILENAME__,                                     \
-                      __FUNCTION__,                                     \
-                      __LINE__,                                         \
-                      ENUM_STR(LOG_LEVEL),                              \
-                      ENUM_STR(COMP),                                   \
-                      MT_thread_getname(),                              \
-                      ## __VA_ARGS__);                                  \
-    }                                                                   \
 
-#define CRITICAL(COMP, MSG, ...)                                              \
-    GDK_TRACER_LOG(M_CRITICAL, COMP, MSG, ## __VA_ARGS__)                     \
-
-#define ERROR(COMP, MSG, ...)                                                 \
-    GDK_TRACER_LOG(M_ERROR, COMP, MSG, ## __VA_ARGS__)                        \
+// If the LOG_LEVEL of the message is one of the following: CRITICAL, ERROR or 
WARNING 
+// it is logged no matter the component. In any other case the component is 
taken into account (needs fix)
+#define GDK_TRACER_LOG(LOG_LEVEL, COMP, MSG, ...)                              
     \
+    if(LOG_LEVEL == M_CRITICAL ||                                              
     \
+       LOG_LEVEL == M_ERROR    ||                                              
     \
+       LOG_LEVEL == M_WARNING  ||                                              
     \
+       (LOG_LEVEL >= CUR_LOG_LEVEL))                                           
     \
+    {                                                                          
     \
+            GDKtracer_log(LOG_LEVEL,                                           
     \
+                        "[%s] %s <%s:%d> (%s - %s) %s # "MSG,                  
     \
+                        GDKtracer_get_timestamp("%Y-%m-%d %H:%M:%S"),          
     \
+                        __FILENAME__,                                          
     \
+                        __FUNCTION__,                                          
     \
+                        __LINE__,                                              
     \
+                        ENUM_STR(LOG_LEVEL),                                   
     \
+                        ENUM_STR(COMP),                                        
     \
+                        MT_thread_getname(),                                   
     \
+                        ## __VA_ARGS__);                                       
     \
+                                                                               
     \
+    }                                                                          
     \
 
-#define WARNING(COMP, MSG, ...)                                               \
-    GDK_TRACER_LOG(M_WARNING, COMP, MSG, ## __VA_ARGS__)                      \
+#define CRITICAL(COMP, MSG, ...)                                               
     \
+    GDK_TRACER_LOG(M_CRITICAL, COMP, MSG, ## __VA_ARGS__)                      
     \
+
+#define ERROR(COMP, MSG, ...)                                                  
     \
+    GDK_TRACER_LOG(M_ERROR, COMP, MSG, ## __VA_ARGS__)                         
     \
 
-#define INFO(COMP, MSG, ...)                                                  \
-    GDK_TRACER_LOG(M_INFO, COMP, MSG, ## __VA_ARGS__)                         \
+#define WARNING(COMP, MSG, ...)                                                
     \
+    GDK_TRACER_LOG(M_WARNING, COMP, MSG, ## __VA_ARGS__)                       
     \
 
-#define DEBUG(COMP, MSG, ...)                                                 \
-    GDK_TRACER_LOG(M_DEBUG, COMP, MSG, ## __VA_ARGS__)                        \
+#define INFO(COMP, MSG, ...)                                                   
     \
+    GDK_TRACER_LOG(M_INFO, COMP, MSG, ## __VA_ARGS__)                          
     \
+
+#define DEBUG(COMP, MSG, ...)                                                  
     \
+    GDK_TRACER_LOG(M_DEBUG, COMP, MSG, ## __VA_ARGS__)                         
     \
 
 
 // GDKtracer Buffer
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to