浏览代码

android: print thread ID with all messages.

legacy
Sam Hocevar sam 13 年前
父节点
当前提交
dead09d2bd
共有 1 个文件被更改,包括 7 次插入3 次删除
  1. +7
    -3
      src/log.cpp

+ 7
- 3
src/log.cpp 查看文件

@@ -21,6 +21,7 @@


#if defined __ANDROID__ #if defined __ANDROID__
# include <android/log.h> # include <android/log.h>
# include <unistd.h> /* for gettid() */
#else #else
# include <cstdarg> # include <cstdarg>
#endif #endif
@@ -73,7 +74,7 @@ void Log::Error(char const *fmt, ...)
void Log::Helper(MessageType type, char const *fmt, va_list ap) void Log::Helper(MessageType type, char const *fmt, va_list ap)
{ {
#if defined __ANDROID__ #if defined __ANDROID__
int prio[] =
int const prio[] =
{ {
ANDROID_LOG_DEBUG, ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO, ANDROID_LOG_INFO,
@@ -81,8 +82,11 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap)
ANDROID_LOG_ERROR 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 #else
char const *prefix[] = char const *prefix[] =


正在加载...
取消
保存