Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: third_party/tcmalloc/chromium/src/base/logging.h

Issue 14845011: Enable tcmalloc's logging in Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed the comment Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698