Exclude dlog dependency when dlog disabled.
[platform/core/uifw/libtbm.git] / src / tbm_log.c
index e4fcd22..7b104e3 100644 (file)
@@ -46,7 +46,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #undef LOG_TAG
 #define LOG_TAG "TBM"
 
+#if ENABLE_DLOG
+#include <dlog.h>
 static unsigned int dlog_enable = 1;
+#else
+#include <stdarg.h>
+static unsigned int dlog_enable = 0;
+#endif
 static unsigned int color_enable = 1;
 
 static unsigned int assert_level = TBM_LOG_LEVEL_NONE;
@@ -67,22 +73,10 @@ tbm_log_enable_color(unsigned int enable)
 void
 tbm_log_enable_dlog(unsigned int enable)
 {
-       const char *str = getenv("TBM_DLOG");
-       if (str)
-               enable = (str[0] == '1') ? 1 : 0;
        dlog_enable = enable;
 }
 
 void
-tbm_log_enable_debug(unsigned int enable)
-{
-       if (enable)
-               tbm_log_debug_level = TBM_LOG_LEVEL_DBG;
-       else
-               tbm_log_debug_level = TBM_LOG_LEVEL_INFO;
-}
-
-void
 tbm_log_set_debug_level(int level)
 {
        tbm_log_debug_level = level;
@@ -172,6 +166,7 @@ tbm_log_print_stdout(int level, const char *fmt, ...)
        va_end(arg);
 }
 
+#if ENABLE_DLOG
 static void
 _tbm_log_dlog_print(int level, const char *fmt, va_list arg)
 {
@@ -195,6 +190,7 @@ _tbm_log_dlog_print(int level, const char *fmt, va_list arg)
        }
        __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmt, arg);
 }
+#endif
 
 void
 tbm_log_print(int level, const char *fmt, ...)
@@ -209,11 +205,15 @@ tbm_log_print(int level, const char *fmt, ...)
        if (level > tbm_log_debug_level)
                return;
 
+#if ENABLE_DLOG
        if (dlog_enable) {
                va_start(arg, fmt);
                _tbm_log_dlog_print(level, fmt, arg);
                va_end(arg);
-       } else {
+       }
+       else
+#endif
+       {
                va_start(arg, fmt);
                _tbm_log_vprint_stdout(level, fmt, arg);
                va_end(arg);
@@ -222,9 +222,3 @@ tbm_log_print(int level, const char *fmt, ...)
        assert(level > assert_level);
 }
 
-void
-tbm_log_reset(void)
-{
-       pthread_mutex_trylock(&log_lock);
-       pthread_mutex_unlock(&log_lock);
-}