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

Initialize log levels in preprocessor


diffs (87 lines):

diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -27,6 +27,7 @@
 
 #include "monetdb_config.h"
 #include "gdk.h"
+#include "gdk_tracer.h"
 
 // We need to get rid of macros defined in gdk.h. Those are using GDKtracer in 
order to produce 
 // messages. At the point malloc is called in gdk_tracer.c (in function 
_GDKtracer_fill_tracer)
@@ -48,7 +49,8 @@ static FILE *output_file;
 static ATOMIC_TYPE CUR_ADAPTER = DEFAULT_ADAPTER;
 
 static LOG_LEVEL CUR_FLUSH_LEVEL = DEFAULT_FLUSH_LEVEL;
-LOG_LEVEL LVL_PER_COMPONENT[COMPONENTS_COUNT];
+// LOG_LEVEL LVL_PER_COMPONENT[COMPONENTS_COUNT] = {[0 ... COMPONENTS_COUNT-1] 
= DEFAULT_LOG_LEVEL};
+
 static bool GDK_TRACER_STOP = false;
 
 static const char *LAYER_STR[] = {
@@ -59,6 +61,10 @@ static const char *ADAPTER_STR[] = {
     FOREACH_ADPTR(GENERATE_STRING)
 };
 
+LOG_LEVEL LVL_PER_COMPONENT[] = {
+    FOREACH_COMP(GENERATE_LOG_LEVEL)
+};
+
 
 // Output error from snprintf of vsnprintf
 static void 
@@ -91,16 +97,6 @@ static void
 }
 
 
-static void
-_GDKtracer_init_components(void)
-{
-    for(int i = 0; i < COMPONENTS_COUNT; i++)
-    {
-        LVL_PER_COMPONENT[i] = DEFAULT_LOG_LEVEL;
-    }
-}
-
-
 static bool
 _GDKtracer_adapter_exists(int *adapter)
 {
@@ -273,7 +269,6 @@ GDKtracer_get_timestamp(char* fmt)
 gdk_return
 GDKtracer_init(void)
 {
-    _GDKtracer_init_components();
     _GDKtracer_create_file();
     return GDK_SUCCEED;
 }
diff --git a/gdk/gdk_tracer.h b/gdk/gdk_tracer.h
--- a/gdk/gdk_tracer.h
+++ b/gdk/gdk_tracer.h
@@ -13,7 +13,7 @@
 #define BUFFER_SIZE 64000
 
 #define DEFAULT_ADAPTER BASIC
-#define DEFAULT_LOG_LEVEL M_CRITICAL
+#define DEFAULT_LOG_LEVEL M_DEBUG
 #define DEFAULT_FLUSH_LEVEL M_INFO
 
 #define FILE_NAME "trace"
@@ -25,7 +25,7 @@
 
 #define GENERATE_ENUM(ENUM) ENUM,
 #define GENERATE_STRING(STRING) #STRING,
-
+#define GENERATE_LOG_LEVEL(COMP) DEFAULT_LOG_LEVEL,
 
 
 // ADAPTERS
@@ -197,7 +197,7 @@ static const char *COMPONENT_STR[] = {
 /*
  * Logging macros 
  */
-extern LOG_LEVEL LVL_PER_COMPONENT[COMPONENTS_COUNT];
+extern LOG_LEVEL LVL_PER_COMPONENT[];
 
 // 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)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to