tpl_util: Added logging for threads. 56/134956/4
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 25 Apr 2017 06:34:21 +0000 (15:34 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 21 Jun 2017 07:04:25 +0000 (16:04 +0900)
Change-Id: I4c89bb464f0becba6bf2b5267777c4b28bfc1b6a
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_utils.h

index c888022..f4bdb47 100644 (file)
@@ -61,6 +61,7 @@ extern unsigned int tpl_dump_lvl;
 #define FONT_GREEN             "\033[32m"      /* for frontend API logs */
 #define FONT_BLUE              "\033[34m"      /* for backend logs */
 #define FONT_MAGENTA   "\033[35m"      /* for debug logs */
+#define FONT_CYAN              "\033[36m"      /* for thread logs */
 
 #ifdef DLOG_DEFAULT_ENABLE
 #define LOG_TAG "TPL"
@@ -71,24 +72,28 @@ extern unsigned int tpl_dump_lvl;
 #define tpl_log_f(t, f, x...)  LOGD(FONT_GREEN t FONT_DEFAULT " " f, ##x)
 #define tpl_log_b(t, f, x...)  LOGD(FONT_BLUE t FONT_DEFAULT " " f, ##x)
 #define tpl_log_d(t, f, x...)  LOGD(FONT_MAGENTA t FONT_DEFAULT " " f, ##x)
+#define tpl_log_t(t, f, x...)  LOGD(FONT_CYAN t FONT_DEFAULT " " f, ##x)
 #define tpl_log_e(t, f, x...)  LOGE(FONT_RED t " " f FONT_DEFAULT, ##x)
 #define tpl_log_w(t, f, x...)  LOGW(FONT_YELLOW t " " f FONT_DEFAULT, ##x)
 #else /* DLOG_DEFAULT_ENABLE */
 #define tpl_log_f(t, f, x...)                                                                                  \
-       fprintf(stderr, FONT_GREEN t FONT_DEFAULT "[(pid:%d)(%s)] " f "\n",     \
-                       getpid(), __func__, ##x)
+       fprintf(stderr, FONT_GREEN t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n",    \
+                       syscall(SYS_gettid), __func__, ##x)
 #define tpl_log_b(t, f, x...)                                                                                  \
-       fprintf(stderr, FONT_BLUE t FONT_DEFAULT "[(pid:%d)(%s)] " f "\n",      \
-                       getpid(), __func__, ##x)
+       fprintf(stderr, FONT_BLUE t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n",     \
+                       syscall(SYS_gettid), __func__, ##x)
 #define tpl_log_d(t, f, x...)                                                                                  \
-       fprintf(stderr, FONT_MAGENTA t FONT_DEFAULT "[(pid:%d)(%s)] " f "\n",\
-                       getpid(), __func__, ##x)
+       fprintf(stderr, FONT_MAGENTA t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n",\
+                       syscall(SYS_gettid), __func__, ##x)
+#define tpl_log_t(t, f, x...)                                                                                  \
+       fprintf(stderr, FONT_CYAN t FONT_DEFAULT "[(tid:%li)(%s)]" f "\n",      \
+                       syscall(SYS_gettid), __func__, ##x)
 #define tpl_log_e(t, f, x...)                                                                                  \
-       fprintf(stderr, FONT_RED t "[(pid:%d)(%s)] " f FONT_DEFAULT "\n",       \
-                       getpid(), __func__, ##x)
+       fprintf(stderr, FONT_RED t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n",      \
+                       syscall(SYS_gettid), __func__, ##x)
 #define tpl_log_w(t, f, x...)                                                                                  \
-       fprintf(stderr, FONT_YELLOW t "[(pid:%d)(%s)] " f FONT_DEFAULT "\n",\
-                       getpid(), __func__, ##x)
+       fprintf(stderr, FONT_YELLOW t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n",\
+                       syscall(SYS_gettid), __func__, ##x)
 #endif /* DLOG_DEFAULT_ENABLE */
 
 
@@ -99,6 +104,13 @@ extern unsigned int tpl_dump_lvl;
 #define TPL_LOG_F(f, x...)             tpl_log_f("[TPL_F]", f, ##x)
 #define TPL_LOG_B(b, f, x...)  tpl_log_b("[TPL_" b "]", f, ##x)
 #define TPL_DEBUG(f, x...)             tpl_log_d("[TPL_DEBUG]", f, ##x)
+#define TPL_LOG_T(b, f, x...)                                                  \
+       {                                                                                                       \
+               if ((int)getpid() != (int)syscall(SYS_gettid))  \
+                       tpl_log_t("[TPL_" b "_T]", f, ##x);                     \
+               else                                                                                    \
+                       tpl_log_b("[TPL_" b "]", f, ##x);                       \
+       }
 #else /* LOG_DEFAULT_ENABLE */
 /*
  * TPL_LOG_LEVEL