diff options
author | SooChan Lim <sc1.lim@samsung.com> | 2021-08-17 16:05:12 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2021-09-02 11:56:36 +0900 |
commit | 92d99019a95ef56925c2cc7aa879d359ffc0d275 (patch) | |
tree | 0fddd1b530a7dfee24efae03f8378303b0470aa7 | |
parent | 3ddd02cb5a99a349dccf89f69e06d45a5a18a910 (diff) | |
download | libtbm-msm-92d99019a95ef56925c2cc7aa879d359ffc0d275.tar.gz libtbm-msm-92d99019a95ef56925c2cc7aa879d359ffc0d275.tar.bz2 libtbm-msm-92d99019a95ef56925c2cc7aa879d359ffc0d275.zip |
add --with-default-dlog option
choose the default log whether to use dlog or printf with this build
option.
Change-Id: I5193e497fbeab99e349fe2533f9c8eaedc43af45
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | packaging/libtbm-msm.spec | 1 | ||||
-rw-r--r-- | src/libhal-backend-tbm-msm/tbm_backend_log.c | 41 | ||||
-rw-r--r-- | src/libhal-backend-tbm-msm/tbm_backend_log.h | 2 |
4 files changed, 47 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 8aa72f2..c7f8e5b 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,13 @@ AC_ARG_WITH(hal-libdir, AS_HELP_STRING([--with-hal-libdir=PATH], [hal backend li AC_DEFINE_UNQUOTED(HAL_LIBDIR, "${HAL_LIBDIR}", [Directory for hal backend library path]) AC_SUBST(HAL_LIBDIR) +# default log system +AC_ARG_WITH(default-dlog, AS_HELP_STRING([--with-default-dlog=yes/no], [whether use dlog as a default log or not]), + [ use_dlog="$withval" ], + [ use_dlog="yes" ]) + +AM_CONDITIONAL(ENABLE_DLOG, test "x$use_dlog" = "xyes") + # for libtbm-msm LIBTBM_MSM_CFLAGS="$LIBDRM_CFLAGS $LIBTBM_CFLAGS $DLOG_CFLAGS $LIBUDEV_CFLAGS $GBM_CFLAGS" LIBTBM_MSM_LIBS="$LIBDRM_LIBS $LIBTBM_LIBS $DLOG_LIBS $LIBUDEV_LIBS $GBM_LIBS" diff --git a/packaging/libtbm-msm.spec b/packaging/libtbm-msm.spec index 930e33d..0edce50 100644 --- a/packaging/libtbm-msm.spec +++ b/packaging/libtbm-msm.spec @@ -38,6 +38,7 @@ cp %{SOURCE1002} . %reconfigure --prefix=%{_prefix} --libdir=%{_libdir}/bufmgr \ --with-hal-libdir=%{_hal_libdir} \ + --with-default-dlog=yes \ --disable-align-eight \ --disable-cachectrl \ CFLAGS="${CFLAGS} -Wall -Werror" LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed" diff --git a/src/libhal-backend-tbm-msm/tbm_backend_log.c b/src/libhal-backend-tbm-msm/tbm_backend_log.c index 58f9a17..2565da1 100644 --- a/src/libhal-backend-tbm-msm/tbm_backend_log.c +++ b/src/libhal-backend-tbm-msm/tbm_backend_log.c @@ -33,7 +33,34 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #undef LOG_TAG #define LOG_TAG "TBM_BACKEND" -int tbm_log_debug_level = TBM_BACKEND_LOG_LEVEL_INFO; +#define COLOR_RED "\x1b[31m" /* for error */ +#define COLOR_YELLOW "\x1b[33m" /* for warning */ +#define COLOR_GREEN "\x1b[32m" /* for info */ +#define COLOR_RESET "\x1b[0m" + +#if ENABLE_DLOG +static unsigned int dlog_enable = 1; +#else +static unsigned int dlog_enable = 0; +#endif +static unsigned int color_enable = 1; + +unsigned int tbm_log_debug_level = TBM_BACKEND_LOG_LEVEL_INFO; + +static void +_tbm_log_vprint_stdout(int level, const char *fmt, va_list arg) +{ + char *lvl_str[] = {"TBM_NON", "TBM_ERR", "TBM_WRN", "TBM_INF", "TBM_DBG"}; + char *color[] = {COLOR_RESET, COLOR_RED, COLOR_YELLOW, COLOR_GREEN, COLOR_RESET}; + + if (color_enable) + printf("%s", color[level]); + printf("[%s]", lvl_str[level]); + if (color_enable) + printf(COLOR_RESET); + vprintf(fmt, arg); + printf("\n"); +} static void _tbm_backend_log_dlog_print(int level, const char *fmt, va_list arg) @@ -67,8 +94,14 @@ tbm_backend_log_print(int level, const char *fmt, ...) if (level > tbm_log_debug_level) return; - va_start(arg, fmt); - _tbm_backend_log_dlog_print(level, fmt, arg); - va_end(arg); + if (dlog_enable) { + va_start(arg, fmt); + _tbm_backend_log_dlog_print(level, fmt, arg); + va_end(arg); + } else { + va_start(arg, fmt); + _tbm_log_vprint_stdout(level, fmt, arg); + va_end(arg); + } } diff --git a/src/libhal-backend-tbm-msm/tbm_backend_log.h b/src/libhal-backend-tbm-msm/tbm_backend_log.h index ff60777..7396a8f 100644 --- a/src/libhal-backend-tbm-msm/tbm_backend_log.h +++ b/src/libhal-backend-tbm-msm/tbm_backend_log.h @@ -32,6 +32,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define __TBM_BACKEND_LOG_H__ #include <sys/syscall.h> +#include <unistd.h> +#include <stdio.h> #include <time.h> #include <dlog.h> |