From 2a4e4b61b4c9f41684958a3b27cb82abcf0cc401 Mon Sep 17 00:00:00 2001 From: George Wright Date: Mon, 27 Feb 2012 15:54:36 -0500 Subject: [PATCH] Add support for android logging to logcat MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: José Fonseca --- CMakeLists.txt | 4 ++++ common/os_posix.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67df4d0..7308fb2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,10 @@ set_target_properties (common PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" ) +if (ANDROID) + target_link_libraries (common log) +endif () + ############################################################################## # API tracers diff --git a/common/os_posix.cpp b/common/os_posix.cpp index 3eebbd8..ebd59a0 100644 --- a/common/os_posix.cpp +++ b/common/os_posix.cpp @@ -44,6 +44,10 @@ #include #endif +#ifdef ANDROID +#include +#endif + #ifndef PATH_MAX #warning PATH_MAX undefined #define PATH_MAX 4096 @@ -153,7 +157,11 @@ log(const char *format, ...) va_list ap; va_start(ap, format); fflush(stdout); +#ifdef ANDROID + __android_log_vprint(ANDROID_LOG_DEBUG, "apitrace", format, ap); +#else vfprintf(stderr, format, ap); +#endif va_end(ap); logging = false; } -- 2.43.0