log: check tdm environment value only init 55/182655/2
authorJunkyeong Kim <jk0430.kim@samsung.com>
Wed, 27 Jun 2018 02:18:16 +0000 (11:18 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 27 Jun 2018 02:36:30 +0000 (02:36 +0000)
Change-Id: I46425da547cc57edc7163d4838e49f92b7ad607a
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
common/tdm_log.c
include/tdm_log.h
src/tdm_config.c

index ac7666d..975eb19 100644 (file)
@@ -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);
 }
index f1b3cdc..de56386 100644 (file)
@@ -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;
index 9918fa4..95f5119 100644 (file)
@@ -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);
        }