#include <unistd.h>
#include <sys/syscall.h>
+#include <time.h>
#ifdef __cplusplus
extern "C" {
TDM_LOG_LEVEL_DBG,
};
+void tdm_log_enable_color(unsigned int enable);
void tdm_log_enable_dlog(unsigned int enable);
void tdm_log_enable_debug(unsigned int enable);
+void tdm_log_set_debug_level(int level);
void tdm_log_print(int level, const char *fmt, ...);
#define TDM_DBG(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_DBG, "[%d][%s %d]"fmt"\n", \
- (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args)
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ tdm_log_print(TDM_LOG_LEVEL_DBG, "[%5d.%06d][%d][%s %d]"fmt"\n", \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
#define TDM_INFO(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_INFO, "[%d][%s %d]"fmt"\n", \
- (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args)
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ tdm_log_print(TDM_LOG_LEVEL_INFO, "[%5d.%06d][%d][%s %d]"fmt"\n", \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
#define TDM_WRN(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_WRN, "[%d][%s %d]"fmt"\n", \
- (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args)
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ tdm_log_print(TDM_LOG_LEVEL_WRN, "[%5d.%06d][%d][%s %d]"fmt"\n", \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
#define TDM_ERR(fmt, args...) \
- tdm_log_print(TDM_LOG_LEVEL_ERR, "[%d][%s %d]"fmt"\n", \
- (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args)
+ do { \
+ struct timespec ts; \
+ clock_gettime(CLOCK_MONOTONIC, &ts); \
+ tdm_log_print(TDM_LOG_LEVEL_ERR, "[%5d.%06d][%d][%s %d]"fmt"\n", \
+ (int)ts.tv_sec, (int)ts.tv_nsec / 1000, \
+ (int)syscall(SYS_gettid), __FUNCTION__, __LINE__, ##args); \
+ } while (0)
#ifdef __cplusplus
}