From 189e36e48cb23005aac962500813fbbf7a0e3a1a Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 27 Jun 2018 11:18:16 +0900 Subject: [PATCH] log: check tdm environment value only init Change-Id: I46425da547cc57edc7163d4838e49f92b7ad607a Signed-off-by: Junkyeong Kim --- common/tdm_log.c | 9 --------- include/tdm_log.h | 1 - src/tdm_config.c | 27 ++++++++++++++++++++++++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/common/tdm_log.c b/common/tdm_log.c index ac7666d..975eb19 100644 --- a/common/tdm_log.c +++ b/common/tdm_log.c @@ -81,9 +81,6 @@ tdm_log_enable_color(unsigned int enable) EXTERN void tdm_log_enable_dlog(unsigned int enable) { - const char *str = getenv("TDM_DLOG"); - if (str) - enable = (str[0] == '1') ? 1 : 0; dlog_enable = enable; TDM_INFO("dlog_enable: %d", dlog_enable); } @@ -91,9 +88,6 @@ tdm_log_enable_dlog(unsigned int enable) EXTERN void tdm_log_set_debug_level(int level) { - const char *str = getenv("TDM_DEBUG_LEVEL"); - if (str) - level = str[0] - '0'; tdm_log_debug_level = level; TDM_INFO("debug_level: %d", tdm_log_debug_level); } @@ -101,9 +95,6 @@ tdm_log_set_debug_level(int level) EXTERN void tdm_log_set_assert_level(int level) { - const char *str = getenv("TDM_ASSERT_LEVEL"); - if (str) - level = str[0] - '0'; assert_level = level; TDM_INFO("assert_level: %d", assert_level); } diff --git a/include/tdm_log.h b/include/tdm_log.h index f1b3cdc..de56386 100644 --- a/include/tdm_log.h +++ b/include/tdm_log.h @@ -71,7 +71,6 @@ void tdm_log_set_assert_level(int level); void tdm_log_set_path(const char *path); void tdm_log_printf(int level, const char *fmt, ...); void tdm_log_print(int level, const char *fmt, ...); - void tdm_log_reset(void); extern unsigned int tdm_log_debug_level; diff --git a/src/tdm_config.c b/src/tdm_config.c index 9918fa4..95f5119 100644 --- a/src/tdm_config.c +++ b/src/tdm_config.c @@ -104,10 +104,24 @@ _tdm_config_check_logs(void) pthread_mutex_unlock(&g_dic_lock); - level = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_LOG_LEVEL, 3); + level = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_LOG_LEVEL, -1); + if (level == -1) { + const char *str = getenv("TDM_DEBUG_LEVEL"); + if (str) + level = str[0] - '0'; + else + level = 3; + } tdm_log_set_debug_level(level); - level = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_ASSERT_LEVEL, 0); + level = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_ASSERT_LEVEL, -1); + if (level == -1) { + const char *str = getenv("TDM_ASSERT_LEVEL"); + if (str) + level = str[0] - '0'; + else + level = 0; + } tdm_log_set_assert_level(level); /* if TDM_CONFIG_KEY_DEBUG_LOG_PATH is setted, TDM_CONFIG_KEY_DEBUG_DLOG will be ignored. */ @@ -116,7 +130,14 @@ _tdm_config_check_logs(void) tdm_log_enable_dlog(0); tdm_log_set_path(path); } else { - int dlog = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_DLOG, 1); + int dlog = tdm_config_get_int(TDM_CONFIG_KEY_DEBUG_DLOG, -1); + if (dlog == -1) { + const char *str = getenv("TDM_DLOG"); + if (str) + dlog = (str[0] == '1') ? 1 : 0; + else + dlog = 1; + } tdm_log_enable_dlog(dlog); } -- 2.7.4