print log with color 06/66806/2
authorBoram Park <boram1288.park@samsung.com>
Thu, 21 Apr 2016 02:01:35 +0000 (11:01 +0900)
committerBoram Park <boram1288.park@samsung.com>
Thu, 21 Apr 2016 07:05:53 +0000 (16:05 +0900)
    red    - error
    yellow - warning
    green  - info
    white  - debug

Change-Id: I9861b058efefc40c5d04677d5c1f952c959ffe60

include/tdm_log.h

index cddf0e67139b591ce26466cdc49e246138bf2190..841cde23d136a42fdb1d75dd4c98a97a5c220789 100644 (file)
@@ -109,6 +109,11 @@ extern int tdm_debug;
 
 #include <stdio.h>
 
+#define COLOR_RED "\x1b[31m"      /* for error */
+#define COLOR_YELLOW "\x1b[33m"   /* for warning */
+#define COLOR_GREEN "\x1b[32m"    /* for info */
+#define COLOR_RESET "\x1b[0m"
+
 #define TDM_DBG(fmt, args...) \
     if (tdm_debug) \
        do { \
@@ -122,7 +127,7 @@ extern int tdm_debug;
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
-               printf("[TDM_INF][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \
+               printf(COLOR_GREEN"[TDM_INF]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \
                        (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \
        } while (0);
 
@@ -130,7 +135,7 @@ extern int tdm_debug;
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
-               printf("[TDM_WRN][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \
+               printf(COLOR_YELLOW"[TDM_WRN]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec,        \
                        (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \
        } while (0);
 
@@ -138,7 +143,7 @@ extern int tdm_debug;
        do { \
                struct timespec ts;     \
                clock_gettime(CLOCK_MONOTONIC, &ts);    \
-               printf("[TDM_ERR][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \
+               printf(COLOR_RED"[TDM_ERR]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec,   \
                        (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \
        } while (0);