Index: third_party/tcmalloc/chromium/src/base/logging.h |
diff --git a/third_party/tcmalloc/chromium/src/base/logging.h b/third_party/tcmalloc/chromium/src/base/logging.h |
index 5b5b5dbfd69566a0b6e9152a0d99725d07765d4e..02f84f4348b4601098dc4ce9fbd4c2b4507c1212 100644 |
--- a/third_party/tcmalloc/chromium/src/base/logging.h |
+++ b/third_party/tcmalloc/chromium/src/base/logging.h |
@@ -56,6 +56,10 @@ |
// do logging on a best-effort basis. |
#if defined(_MSC_VER) |
#define WRITE_TO_STDERR(buf, len) WriteToStderr(buf, len); // in port.cc |
+#elif defined(__ANDROID__) || defined(ANDROID) |
+#include <android/log.h> |
+#define WRITE_TO_STDERR(buf, len) \ |
+ __android_log_write(ANDROID_LOG_ERROR, "gperftools", buf) |
#elif defined(HAVE_SYS_SYSCALL_H) |
#include <sys/syscall.h> |
#define WRITE_TO_STDERR(buf, len) syscall(SYS_write, STDERR_FILENO, buf, len) |
@@ -204,7 +208,30 @@ inline void LogPrintf(int severity, const char* pat, va_list ap) { |
assert(strlen(buf)+1 < sizeof(buf)); |
strcat(buf, "\n"); |
} |
+#if defined(__ANDROID__) || defined(ANDROID) |
+ android_LogPriority priority = ANDROID_LOG_UNKNOWN; |
+ switch (severity) { |
+ case INFO: { |
+ priority = ANDROID_LOG_INFO; |
+ break; |
+ } |
+ case WARNING: { |
+ priority = ANDROID_LOG_WARN; |
+ break; |
+ } |
+ case ERROR: { |
+ priority = ANDROID_LOG_ERROR; |
+ break; |
+ } |
+ case FATAL: { |
+ priority = ANDROID_LOG_FATAL; |
+ break; |
+ } |
+ } |
+ __android_log_write(priority, "gperftools", buf); |
+#else // defined(__ANDROID__) || defined(ANDROID) |
WRITE_TO_STDERR(buf, strlen(buf)); |
+#endif // defined(__ANDROID__) || defined(ANDROID) |
if ((severity) == FATAL) { |
// LOG(FATAL) indicates a big problem, so don't run atexit() calls |
tcmalloc::Abort(); |