From 8854eef9eb4718b0145d639b1bf37c610a910632 Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Mon, 6 May 2019 13:52:32 +0800 Subject: Re-implement _eglLog based on dlog _eglLog is a basic log function for mesa, re-implement it based on dlog here for debug purpose. Log level can be changed by setting environment variable EGL_LOG_LEVEL. Change-Id: Ib356d14d631fcda0d9c45f0e442f02981b0377be Signed-off-by: Zhaowei Yuan --- configure.ac | 2 +- packaging/mesa.spec | 1 + src/egl/main/egllog.c | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ebcdc3eb20e..399c98c3520 100644 --- a/configure.ac +++ b/configure.ac @@ -1896,7 +1896,7 @@ for plat in $platforms; do ;; tizen) - PKG_CHECK_MODULES([TIZEN], [tpl-egl libtbm libtdm wayland-client]) + PKG_CHECK_MODULES([TIZEN], [tpl-egl libtbm libtdm wayland-client dlog]) DEFINES="$DEFINES -DHAVE_TIZEN_PLATFORM" ;; *) diff --git a/packaging/mesa.spec b/packaging/mesa.spec index 000fb577e48..31cea6fe688 100644 --- a/packaging/mesa.spec +++ b/packaging/mesa.spec @@ -33,6 +33,7 @@ BuildRequires: pkgconfig(tpl-egl) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libtdm) BuildRequires: pkgconfig(zlib) +BuildRequires: pkgconfig(dlog) %ifarch x86_64 %ix86 BuildRequires: pkgconfig(libdrm_intel) >= 2.4.24 %endif diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index c223f49b0fe..de4bee26c0e 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -44,6 +44,10 @@ #include "util/macros.h" #include "egllog.h" +#ifdef HAVE_TIZEN_PLATFORM +#define LOG_TAG "MESA" +#include +#endif #ifdef HAVE_ANDROID_PLATFORM #define LOG_TAG "EGL-MAIN" @@ -56,7 +60,7 @@ #endif /* HAVE_ANDROID_PLATFORM */ #define MAXSTRING 1000 -#define FALLBACK_LOG_LEVEL _EGL_WARNING +#define FALLBACK_LOG_LEVEL _EGL_FATAL static struct { @@ -78,6 +82,7 @@ static const char *level_strings[] = { }; +#ifndef HAVE_TIZEN_PLATFORM /** * The default logger. It prints the message to stderr. */ @@ -96,6 +101,7 @@ _eglDefaultLogger(EGLint level, const char *msg) fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg); #endif /* HAVE_ANDROID_PLATFORM */ } +#endif /** @@ -153,13 +159,40 @@ _eglLog(EGLint level, const char *fmtStr, ...) mtx_lock(&logging.mutex); +#ifdef HAVE_TIZEN_PLATFORM + log_priority dlog_prio; + + switch (level) { + case _EGL_FATAL: + dlog_prio = DLOG_ERROR; + break; + case _EGL_WARNING: + dlog_prio = DLOG_WARN; + break; + case _EGL_INFO: + dlog_prio = DLOG_INFO; + break; + case _EGL_DEBUG: + dlog_prio = DLOG_DEBUG; + break; + default: + return; + } +#endif + va_start(args, fmtStr); +#ifdef HAVE_TIZEN_PLATFORM + __dlog_vprint(LOG_ID_SYSTEM, dlog_prio, LOG_TAG, fmtStr, args); +#else ret = vsnprintf(msg, MAXSTRING, fmtStr, args); if (ret < 0 || ret >= MAXSTRING) strcpy(msg, ""); +#endif va_end(args); +#ifndef HAVE_TIZEN_PLATFORM _eglDefaultLogger(level, msg); +#endif mtx_unlock(&logging.mutex); -- cgit v1.2.3