OSDN Git Service

android: print debug info to logcat
authorWuZhen <wuzhen@jidemail.com>
Wed, 20 Jan 2016 07:52:29 +0000 (15:52 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 3 Aug 2016 10:55:06 +0000 (18:55 +0800)
Redirect logs printed to stderr to logcat.

NO_REF_TASK
Tested: local run

Change-Id: I58e3966a608af361b86c54b4c95a92561b711968
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
src/gallium/auxiliary/os/os_misc.c
src/gallium/auxiliary/util/u_debug.c
src/gallium/targets/dri/Android.mk
src/mesa/main/errors.c

index d6b83e9..8297caf 100644 (file)
 
 #endif
 
-
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS)
+#if defined(PIPE_OS_ANDROID)
+#  define LOG_TAG "gallium"
+#  include <log/log.h>
+#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_SOLARIS)
 #  include <unistd.h>
 #elif defined(PIPE_OS_APPLE) || defined(PIPE_OS_BSD)
 #  include <sys/sysctl.h>
@@ -89,6 +91,12 @@ os_log_message(const char *message)
       fflush(fout);
    }
 #else /* !PIPE_SUBSYSTEM_WINDOWS */
+#if defined(PIPE_OS_ANDROID)
+   if (fout == stderr) {
+      ALOGD("%s", message);
+      return;
+   }
+#endif
    fflush(stdout);
    fputs(message, fout);
    fflush(fout);
index 3a94b75..e18e8ab 100644 (file)
@@ -55,7 +55,7 @@ void
 _debug_vprintf(const char *format, va_list ap)
 {
    static char buf[4096] = {'\0'};
-#if defined(PIPE_OS_WINDOWS) || defined(PIPE_SUBSYSTEM_EMBEDDED)
+#if defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_ANDROID) || defined(PIPE_SUBSYSTEM_EMBEDDED)
    /* We buffer until we find a newline. */
    size_t len = strlen(buf);
    int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
index 03c3795..a14d449 100644 (file)
@@ -46,6 +46,7 @@ LOCAL_CFLAGS :=
 
 LOCAL_SHARED_LIBRARIES := \
        libdl \
+       liblog \
        libglapi \
        libexpat \
 
index 9932b4a..53a8436 100644 (file)
 #include "util/hash_table.h"
 #include "util/simple_list.h"
 
+#if defined(ANDROID)
+#  define LOG_TAG "mesa"
+#  include <log/log.h>
+#endif
 
 static FILE *LogFile = NULL;
 
@@ -95,6 +99,10 @@ output_if_debug(const char *prefixString, const char *outputString,
          _mesa_snprintf(buf, sizeof(buf), "%s: %s%s", prefixString, outputString, newline ? "\n" : "");
          OutputDebugStringA(buf);
       }
+#elif defined(ANDROID)
+      {
+         ALOGD("%s: %s", prefixString, outputString);
+      }
 #endif
    }
 }