Bug 702029 - Push all console logging to androids adb logcat. r=blassey
authorDoug Turner <dougt@dougt.org>
Mon, 14 Nov 2011 19:12:20 -0800
changeset 80241 09440352f371e49af29acb3532b460685e1a60dc
parent 80240 5384d8c6c527e771ca5e398caf195ea714b7e836
child 80242 9ae1d4f44b8bed83024c14403d468fa45efc7fd5
push id323
push userrcampbell@mozilla.com
push dateTue, 15 Nov 2011 21:58:36 +0000
treeherderfx-team@3ea216303184 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs702029
milestone11.0a1
Bug 702029 - Push all console logging to androids adb logcat. r=blassey
xpcom/base/nsConsoleService.cpp
--- a/xpcom/base/nsConsoleService.cpp
+++ b/xpcom/base/nsConsoleService.cpp
@@ -48,16 +48,20 @@
 #include "nsIProxyObjectManager.h"
 #include "nsCOMArray.h"
 #include "nsThreadUtils.h"
 
 #include "nsConsoleService.h"
 #include "nsConsoleMessage.h"
 #include "nsIClassInfoImpl.h"
 
+#if defined(ANDROID)
+#include <android/log.h>
+#endif
+
 using namespace mozilla;
 
 NS_IMPL_THREADSAFE_ADDREF(nsConsoleService)
 NS_IMPL_THREADSAFE_RELEASE(nsConsoleService)
 NS_IMPL_CLASSINFO(nsConsoleService, NULL, nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON, NS_CONSOLESERVICE_CID)
 NS_IMPL_QUERY_INTERFACE1_CI(nsConsoleService, nsIConsoleService)
 NS_IMPL_CI_INTERFACE_GETTER1(nsConsoleService, nsIConsoleService)
 
@@ -130,16 +134,26 @@ nsConsoleService::LogMessage(nsIConsoleM
 
     /*
      * Lock while updating buffer, and while taking snapshot of
      * listeners array.
      */
     {
         MutexAutoLock lock(mLock);
 
+#if defined(ANDROID)
+        {
+            nsXPIDLString msg;
+            message->GetMessageMoz(getter_Copies(msg));
+            __android_log_print(ANDROID_LOG_ERROR, "Gecko *** Console Service *** ",
+                        "%s",
+                        NS_LossyConvertUTF16toASCII(msg).get());
+        }
+#endif
+
         /*
          * If there's already a message in the slot we're about to replace,
          * we've wrapped around, and we need to release the old message.  We
          * save a pointer to it, so we can release below outside the lock.
          */
         retiredMessage = mMessages[mCurrent];
         
         mMessages[mCurrent++] = message;