From dead09d2bd4b10949f0752a9cbd4a6f2363c3193 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 23 Sep 2012 15:35:20 +0000 Subject: [PATCH] android: print thread ID with all messages. --- src/log.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/log.cpp b/src/log.cpp index 81821644..19436b44 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -21,6 +21,7 @@ #if defined __ANDROID__ # include +# include /* for gettid() */ #else # include #endif @@ -73,7 +74,7 @@ void Log::Error(char const *fmt, ...) void Log::Helper(MessageType type, char const *fmt, va_list ap) { #if defined __ANDROID__ - int prio[] = + int const prio[] = { ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, @@ -81,8 +82,11 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap) ANDROID_LOG_ERROR }; - //__android_log_print(prio[type], "LOL", "thread %ld", pthread_self()); - __android_log_vprint(prio[type], "LOL", fmt, ap); + char buf[4096]; + vsnprintf(buf, 4095, fmt, ap); + buf[4095] = '\0'; + + __android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), buf); #else char const *prefix[] =