Mesa (master): egl: simplify the Android logger

Emil Velikov evelikov at kemper.freedesktop.org
Thu May 11 13:09:27 UTC 2017


Module: Mesa
Branch: master
Commit: 1ce58536ec23e1253a9bf5949ad3f3396d160b83
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ce58536ec23e1253a9bf5949ad3f3396d160b83

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Mon May  8 15:38:11 2017 +0100

egl: simplify the Android logger

Drop the unsupported pre-JellyBean macros and use a simple egl2android
mapping. With this we loose the explicit abort() provided by LOG_FATAL,
although Mesa already already calls exit(1) in case of a fatal errors.

Suggested-by: Rob Herring <robh at kernel.org>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Rob Herring <robh at kernel.org>

---

 src/egl/main/egllog.c | 34 +++++++---------------------------
 1 file changed, 7 insertions(+), 27 deletions(-)

diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
index bf0ee017b8..6de2a50b45 100644
--- a/src/egl/main/egllog.c
+++ b/src/egl/main/egllog.c
@@ -49,17 +49,6 @@
 #define LOG_TAG "EGL-MAIN"
 #include <cutils/log.h>
 
-/* support versions < JellyBean */
-#ifndef ALOGW
-#define ALOGW LOGW
-#endif
-#ifndef ALOGD
-#define ALOGD LOGD
-#endif
-#ifndef ALOGI
-#define ALOGI LOGI
-#endif
-
 #endif /* HAVE_ANDROID_PLATFORM */
 
 #define MAXSTRING 1000
@@ -92,22 +81,13 @@ static void
 _eglDefaultLogger(EGLint level, const char *msg)
 {
 #ifdef HAVE_ANDROID_PLATFORM
-   switch (level) {
-   case _EGL_DEBUG:
-      ALOGD("%s", msg);
-      break;
-   case _EGL_INFO:
-      ALOGI("%s", msg);
-      break;
-   case _EGL_WARNING:
-      ALOGW("%s", msg);
-      break;
-   case _EGL_FATAL:
-      LOG_FATAL("%s", msg);
-      break;
-   default:
-      break;
-   }
+   static const int egl2alog[] = {
+      [_EGL_FATAL] = LOG_ERROR,
+      [_EGL_WARNING]  = LOG_WARN,
+      [_EGL_INFO] = LOG_INFO,
+      [_EGL_DEBUG] = LOG_DEBUG,
+   };
+   ALOG(egl2alog[level], LOG_TAG, "%s", msg);
 #else
    fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg);
 #endif /* HAVE_ANDROID_PLATFORM */




More information about the mesa-commit mailing list