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

Unified Diff: base/logging.cc

Issue 7238012: Upstream android debug and log related files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the android guard around ctype.h Created 9 years, 5 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 | « base/logging.h ('k') | base/string_number_conversions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index e5c8c8df6dc7e1b84eaaa4e7193cfc789deb4dfc..11ad9357d6afbf26050b5abbd35c0a1b2c70f4e7 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -58,6 +58,10 @@ typedef pthread_mutex_t* MutexHandle;
#include "base/safe_strerror_posix.h"
#endif
+#if defined(OS_ANDROID)
+#include <android/log.h>
+#endif
+
namespace logging {
DcheckState g_dcheck_state = DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS;
@@ -129,6 +133,8 @@ int32 CurrentThreadId() {
return mach_thread_self();
#elif defined(OS_LINUX)
return syscall(__NR_gettid);
+#elif defined(OS_ANDROID)
+ return gettid();
#elif defined(OS_FREEBSD)
// TODO(BSD): find a better thread ID
return reinterpret_cast<int64>(pthread_self());
@@ -546,7 +552,9 @@ LogMessage::LogMessage(const char* file, int line, LogSeverity severity,
}
LogMessage::~LogMessage() {
-#ifndef NDEBUG
+ // TODO(port): enable stacktrace generation on LOG_FATAL once backtrace are
+ // working in Android.
+#if !defined(NDEBUG) && !defined(OS_ANDROID)
if (severity_ == LOG_FATAL) {
// Include a stack trace on a fatal.
base::debug::StackTrace trace;
@@ -568,6 +576,24 @@ LogMessage::~LogMessage() {
logging_destination == LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG) {
#if defined(OS_WIN)
OutputDebugStringA(str_newline.c_str());
+#elif defined(OS_ANDROID)
+ android_LogPriority priority = ANDROID_LOG_UNKNOWN;
+ switch (severity_) {
+ case LOG_INFO:
+ priority = ANDROID_LOG_INFO;
+ break;
+ case LOG_WARNING:
+ priority = ANDROID_LOG_WARN;
+ break;
+ case LOG_ERROR:
+ case LOG_ERROR_REPORT:
+ priority = ANDROID_LOG_ERROR;
+ break;
+ case LOG_FATAL:
+ priority = ANDROID_LOG_FATAL;
+ break;
+ }
+ __android_log_write(priority, "chromium", str_newline.c_str());
#endif
fprintf(stderr, "%s", str_newline.c_str());
fflush(stderr);
« no previous file with comments | « base/logging.h ('k') | base/string_number_conversions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698