Change-Id: I6f903828f1e22f7c3dfed074173f9e5e78636011
#include <assert.h>
#include <sys/syscall.h>
#include <dlog.h>
+#include <pthread.h>
#include "tdm.h"
#include "tdm_log.h"
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)
{
{
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