#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"
#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 */
#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