#define LOG_TAG "TDM"
static unsigned int dlog_enable;
+static unsigned int color_enable = 1;
static unsigned int debug_level = TDM_LOG_LEVEL_INFO;
static unsigned int need_check_env = 1;
}
EXTERN void
+tdm_log_enable_color(unsigned int enable)
+{
+ color_enable = enable;
+}
+
+EXTERN void
tdm_log_enable_dlog(unsigned int enable)
{
dlog_enable = enable;
clock_gettime(CLOCK_MONOTONIC, &ts);
- printf("%s", color[level]);
+ if (color_enable)
+ printf("%s", color[level]);
printf("[%s]", lvl_str[level]);
- printf(COLOR_RESET"[%d.%06d]", (int)ts.tv_sec, (int)ts.tv_nsec / 1000);
+ if (color_enable)
+ printf(COLOR_RESET);
+ printf("[%d.%06d]", (int)ts.tv_sec, (int)ts.tv_nsec / 1000);
va_start(arg, fmt);
vprintf(fmt, arg);
va_end(arg);
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);
if (debug)
tdm_display_enable_dump(debug);
+ debug = getenv("TDM_DEBUG_PATH");
+ if (debug)
+ tdm_display_enable_path(debug);
+
private_display = calloc(1, sizeof(tdm_private_display));
if (!private_display) {
ret = TDM_ERROR_OUT_OF_MEMORY;
tdm_debug_module |= TDM_DEBUG_THREAD;
else if (!strncmp(arg, "mutex", 5))
tdm_debug_module |= TDM_DEBUG_MUTEX;
+ else if (!strncmp(arg, "vblank", 6))
+ tdm_debug_module |= TDM_DEBUG_VBLANK;
else
return TDM_ERROR_BAD_REQUEST;
return TDM_ERROR_NONE;
}
+
+INTERN tdm_error
+tdm_display_enable_path(const char *path)
+{
+ static int old_stdout = -1;
+ char fd_name[TDM_PATH_LEN];
+ int log_fd = -1;
+ FILE *log_fl;
+
+ if (old_stdout == -1)
+ old_stdout = dup(STDOUT_FILENO);
+
+ tdm_log_enable_dlog(0);
+
+ snprintf(fd_name, TDM_PATH_LEN, "%s", path);
+
+ log_fl = fopen(fd_name, "a");
+ if (!log_fl) {
+ TDM_ERR("failed: open file(%s)\n", fd_name);
+ return TDM_ERROR_OPERATION_FAILED;
+ }
+
+ fflush(stderr);
+ close(STDOUT_FILENO);
+
+ setvbuf(log_fl, NULL, _IOLBF, 512);
+ log_fd = fileno(log_fl);
+
+ dup2(log_fd, STDOUT_FILENO);
+ fclose(log_fl);
+
+ return TDM_ERROR_NONE;
+}
{
static int old_stdout = -1;
char fd_name[TDM_PATH_LEN];
- int log_fd = -1;
- FILE *log_fl;
char *path;
if (argc < 3) {
else
snprintf(fd_name, TDM_PATH_LEN, "%s", path);
}
+ tdm_log_enable_color(0);
}
- log_fl = fopen(fd_name, "a");
- if (!log_fl) {
- TDM_SNPRINTF(reply, len, "failed: open file(%s)\n", fd_name);
+ if (tdm_display_enable_path((const char*)fd_name) != TDM_ERROR_NONE) {
+ TDM_SNPRINTF(reply, len, "failed: '%s'\n", path);
return;
}
- fflush(stderr);
- close(STDOUT_FILENO);
-
- setvbuf(log_fl, NULL, _IOLBF, 512);
- log_fd = fileno(log_fl);
-
- dup2(log_fd, STDOUT_FILENO);
- fclose(log_fl);
done:
TDM_SNPRINTF(reply, len, "log path: '%s'\n", path);
}
tdm_display_enable_debug_module(const char*modules);
tdm_error
tdm_display_enable_dump(const char *dump_str);
+tdm_error
+tdm_display_enable_path(const char *path);
/**
* @brief The tdm vblank object