#include <assert.h>
#include <sys/syscall.h>
#include <dlog.h>
+#include <pthread.h>
#include "tdm.h"
#include "tdm_log.h"
#undef LOG_TAG
#define LOG_TAG "TDM"
-static unsigned int dlog_enable;
+static unsigned int dlog_enable = 1;
static unsigned int color_enable = 1;
static unsigned int debug_level = TDM_LOG_LEVEL_INFO;
static unsigned int need_check_env = 1;
+static unsigned int log_lock_init;
+static pthread_mutex_t log_lock;
+
static void
_tdm_log_check_env(void)
{
debug_level = TDM_LOG_LEVEL_DBG;
str = getenv("TDM_DLOG");
- if (str && (strstr(str, "1")))
- dlog_enable = 1;
+ if (str && (strstr(str, "0")))
+ dlog_enable = 0;
}
EXTERN void
{
va_list arg;
+ if (!log_lock_init) {
+ log_lock_init = 1;
+ pthread_mutex_init(&log_lock, NULL);
+
+ }
+
if (need_check_env) {
need_check_env = 0;
_tdm_log_check_env();
clock_gettime(CLOCK_MONOTONIC, &ts);
+ pthread_mutex_lock(&log_lock);
+
if (color_enable)
printf("%s", color[level]);
printf("[%s]", lvl_str[level]);
va_start(arg, fmt);
vprintf(fmt, arg);
va_end(arg);
+
+ pthread_mutex_unlock(&log_lock);
}
#ifdef TDM_CONFIG_ASSERT