enhance debug log
authorBoram Park <boram1288.park@samsung.com>
Mon, 30 Nov 2015 10:49:38 +0000 (19:49 +0900)
committerBoram Park <boram1288.park@samsung.com>
Mon, 30 Nov 2015 10:49:38 +0000 (19:49 +0900)
Change-Id: Iffd487b12c93e362cd61bb4e8c446eb40ae56fff

include/tdm_log.h
src/tdm.c

index f0b999b..d12129d 100644 (file)
@@ -55,7 +55,7 @@ extern int tdm_debug;
 #define LOG_TAG "TDM"
 
 #define TDM_DBG(fmt, args...) \
-    if (tdm_debug) \
+       if (tdm_debug < 1) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -65,6 +65,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_INFO(fmt, args...) \
+       if (tdm_debug < 2) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -74,6 +75,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_WRN(fmt, args...) \
+       if (tdm_debug < 3) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -83,6 +85,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_ERR(fmt, args...) \
+       if (tdm_debug < 4) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -97,7 +100,7 @@ extern int tdm_debug;
 #include <time.h>
 
 #define TDM_DBG(fmt, args...) \
-    if (tdm_debug) \
+       if (tdm_debug < 1) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -106,6 +109,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_INFO(fmt, args...) \
+       if (tdm_debug < 2) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -114,6 +118,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_WRN(fmt, args...) \
+       if (tdm_debug < 3) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
@@ -122,6 +127,7 @@ extern int tdm_debug;
        } while (0);
 
 #define TDM_ERR(fmt, args...) \
+       if (tdm_debug < 4) \
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
index 581b301..2a1ae1c 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -465,7 +465,7 @@ tdm_display_update(tdm_display *dpy)
 #define SUFFIX_MODULE    ".so"
 #define DEFAULT_MODULE   "libtdm-default"SUFFIX_MODULE
 
-int tdm_debug;
+int tdm_debug = 2;
 
 static tdm_private_display *g_private_display;
 static pthread_mutex_t gLock = PTHREAD_MUTEX_INITIALIZER;
@@ -693,8 +693,12 @@ tdm_display_init(tdm_error *error)
     }
 
     debug = getenv("TDM_DEBUG");
-    if (debug && (strstr(debug, "1")))
-        tdm_debug = 1;
+    if (debug)
+    {
+        char buf[64];
+        snprintf (buf, sizeof buf, "%s", debug);
+        tdm_debug = atoi(buf);
+    }
 
     private_display = calloc(1, sizeof(tdm_private_display));
     if (!private_display)