From c1a7326e3ebf0f93e78c5d317ea7debe2fea207d Mon Sep 17 00:00:00 2001 From: Kichan Kwon Date: Fri, 4 Nov 2016 18:39:49 +0900 Subject: [PATCH] libdlog : control platform debug log by modifying conf file - If debugmode is set to 0, libdlog doesn't write platform debug log - Debugmode doesn't impact on Public API (dlog_(v)print) - Normal user can't modify it Change-Id: Ib1a278412baaa5a2ff64612b786a59adffb7c849 Signed-off-by: Kichan Kwon --- configs/dlog.conf.journal | 3 --- configs/dlog.conf.kmsg | 1 + configs/dlog.conf.logger | 1 + configs/dlog.conf.pipe | 3 +++ configure.ac | 12 ------------ packaging/dlog.spec | 1 - src/libdlog/log.c | 15 +++++++++------ 7 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 configs/dlog.conf.journal diff --git a/configs/dlog.conf.journal b/configs/dlog.conf.journal deleted file mode 100644 index fade87a..0000000 --- a/configs/dlog.conf.journal +++ /dev/null @@ -1,3 +0,0 @@ -plog=1 -limiter=0 -limiter|*|*=allow diff --git a/configs/dlog.conf.kmsg b/configs/dlog.conf.kmsg index f2eeb81..e4dab07 100644 --- a/configs/dlog.conf.kmsg +++ b/configs/dlog.conf.kmsg @@ -1,5 +1,6 @@ backend=kmsg plog=1 +debugmode=1 limiter=0 limiter|*|*=allow main_size=1048576 diff --git a/configs/dlog.conf.logger b/configs/dlog.conf.logger index a7a7eb9..fc10387 100644 --- a/configs/dlog.conf.logger +++ b/configs/dlog.conf.logger @@ -1,5 +1,6 @@ backend=logger plog=1 +debugmode=1 limiter=0 limiter|*|*=allow main=/dev/log_main diff --git a/configs/dlog.conf.pipe b/configs/dlog.conf.pipe index 116d038..978ba7d 100644 --- a/configs/dlog.conf.pipe +++ b/configs/dlog.conf.pipe @@ -9,6 +9,9 @@ backend=pipe # Platform logging. Whether logging happens at all. plog=1 +# Debugmode - whether write platform debug log or not +debugmode=1 + # Limiter - whether it's enabled and the rules (check the documentation for how to create rules). limiter=0 limiter|*|*=allow diff --git a/configure.ac b/configure.ac index 425e046..8717157 100644 --- a/configure.ac +++ b/configure.ac @@ -14,18 +14,6 @@ AC_PROG_CC AC_PROG_GCC_TRADITIONAL AC_PROG_LIBTOOL -# check binary type for dlog debug mode -AC_ARG_ENABLE([debug_mode], - AS_HELP_STRING([--enable-debug_mode Turn on debug_mode]), - [debug_mode=yes], - debug_mode=no) -if test "x$debug_mode" = "xyes" ; then - DEBUG_CFLAGS+=" -DDLOG_DEBUG_ENABLE" -fi -AC_ARG_ENABLE([debug_enable], - AS_HELP_STRING([--enable-debug_enable Turn on debug_enable]), - [debug_enable=yes], - debug_enable=no) AC_SUBST(DEBUG_CFLAGS) # Checks for libraries. # Checks for header files. diff --git a/packaging/dlog.spec b/packaging/dlog.spec index e5836fc..90cc166 100644 --- a/packaging/dlog.spec +++ b/packaging/dlog.spec @@ -89,7 +89,6 @@ cp %{SOURCE103} . cp %{SOURCE104} . %autogen --disable-static %configure --disable-static \ - --enable-debug_mode \ TZ_SYS_ETC=%{TZ_SYS_ETC} make %{?jobs:-j%jobs} \ CFLAGS+=-DTZ_SYS_ETC=\\\"%{TZ_SYS_ETC}\\\" diff --git a/src/libdlog/log.c b/src/libdlog/log.c index 6ec03c7..854185d 100644 --- a/src/libdlog/log.c +++ b/src/libdlog/log.c @@ -47,6 +47,7 @@ extern void __dlog_init_android(); static int limiter; static int plog; static int debugmode; +static int fatal_assert; /** * @brief Null handler @@ -137,6 +138,10 @@ static void __configure(void) else if (!strncmp(conf_value, "logger", sizeof("logger") + 1)) __dlog_init_android(); + fatal_assert = access(DEBUGMODE_FILE, F_OK); + conf_value = log_config_get(&conf, "debugmode"); + debugmode = atoi(conf_value); + log_config_free(&conf); return; @@ -156,7 +161,7 @@ static void __dlog_init(void) __configure(); is_initialized = 1; } - debugmode = access(DEBUGMODE_FILE, F_OK) != -1 ? 1 : 0; + pthread_mutex_unlock(&log_init_lock); } @@ -167,7 +172,7 @@ static void __dlog_init(void) */ void __dlog_fatal_assert(int prio) { - assert(debugmode || !(prio == DLOG_FATAL)); + assert(!fatal_assert || (prio != DLOG_FATAL)); } /** @@ -182,11 +187,9 @@ void __dlog_fatal_assert(int prio) */ static int dlog_should_log(log_id_t log_id, const char* tag, int prio) { - -#ifndef DLOG_DEBUG_ENABLE - if (prio <= DLOG_DEBUG) + if (!debugmode && prio <= DLOG_DEBUG) return DLOG_ERROR_INVALID_PARAMETER; -#endif + if (!tag) return DLOG_ERROR_INVALID_PARAMETER; -- 2.7.4