Bug 1071359 - Make WebRTC on B2G uses logcat as logging sub-system. r=jesup
authorChangbin Park <pchangbin@gmail.com>
Tue, 23 Sep 2014 13:57:33 +0900
changeset 206826 088fc2a2dfb917426ae2587fba5f110770471805
parent 206825 b19b42b1ef88ff2f0529f2c1a378a297263aa29c
child 206827 2c55ce47a875e22241020f0ad21dcd5659c37989
push id10901
push userryanvm@gmail.com
push dateWed, 24 Sep 2014 13:12:02 +0000
treeherderb2g-inbound@088fc2a2dfb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs1071359
milestone35.0a1
Bug 1071359 - Make WebRTC on B2G uses logcat as logging sub-system. r=jesup
media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
media/webrtc/trunk/webrtc/build/common.gypi
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -2,16 +2,19 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WebRtcLog.h"
 
 #include "prlog.h"
 #include "prenv.h"
 #include "webrtc/system_wrappers/interface/trace.h"
+#ifdef WEBRTC_GONK
+#include "webrtc/system_wrappers/interface/logcat_trace_context.h"
+#endif
 
 #include "nscore.h"
 #ifdef MOZILLA_INTERNAL_API
 #include "nsString.h"
 #include "mozilla/Preferences.h"
 #else
 #include "nsStringAPI.h"
 #endif
@@ -48,16 +51,20 @@ public:
 #ifdef PR_LOGGING
     PRLogModuleInfo *log = GetWebRtcTraceLog();
     PR_LOG(log, PR_LOG_DEBUG, ("%s", message));
 #endif
   }
 };
 
 static WebRtcTraceCallback gWebRtcCallback;
+#ifdef WEBRTC_GONK
+static webrtc::LogcatTraceContext gWebRtcLogcatCallback;
+#endif
+
 
 #ifdef MOZILLA_INTERNAL_API
 void GetWebRtcLogPrefs(uint32_t *aTraceMask, nsACString* aLogFile, nsACString *aAECLogDir, bool *aMultiLog)
 {
   *aMultiLog = mozilla::Preferences::GetBool("media.webrtc.debug.multi_log");
   *aTraceMask = mozilla::Preferences::GetUint("media.webrtc.debug.trace_mask");
   mozilla::Preferences::GetCString("media.webrtc.debug.log_file", aLogFile);
   mozilla::Preferences::GetCString("media.webrtc.debug.aec_log_dir", aAECLogDir);
@@ -110,18 +117,23 @@ void ConfigWebRtcLog(uint32_t trace_mask
     logFile.Assign(default_log);
   } else {
     logFile.Assign(temp_dir);
     logFile.Append('/');
     aecLogDir = logFile;
     logFile.Append(default_log);
   }
 #elif defined(ANDROID)
+#ifdef WEBRTC_GONK
+  // Special case: use callback to log through logcat.
+  logFile.Assign("logcat");
+#else
   // Special case: use callback to pipe to NSPR logging.
   logFile.Assign("nspr");
+#endif
   // for AEC, force the user to specify a directory
   aecLogDir.Assign("/dev/null");
 #else
   // UNIX-like place for the others
   logFile.Assign("/tmp/");
   aecLogDir = logFile;
   logFile.Append(default_log);
 #endif
@@ -132,16 +144,20 @@ void ConfigWebRtcLog(uint32_t trace_mask
     aAECLogDir = aecLogDir;
   }
 
   webrtc::Trace::set_level_filter(trace_mask);
   webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
   if (trace_mask != 0) {
     if (aLogFile.EqualsLiteral("nspr")) {
       webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
+#ifdef WEBRTC_GONK
+    } else if (aLogFile.EqualsLiteral("logcat")) {
+      webrtc::Trace::SetTraceCallback(&gWebRtcLogcatCallback);
+#endif
     } else {
       webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
     }
   }
   return;
 }
 
 void StartWebRtcLog(uint32_t log_level)
--- a/media/webrtc/trunk/webrtc/build/common.gypi
+++ b/media/webrtc/trunk/webrtc/build/common.gypi
@@ -183,16 +183,17 @@
       # To include the top-level directory when building in Chrome, so we can
       # use full paths (e.g. headers inside testing/ or third_party/).
       '<(DEPTH)',
     ],
     'conditions': [
       ['moz_widget_toolkit_gonk==1', {
         'defines' : [
           'WEBRTC_GONK',
+          'WEBRTC_DIRECT_TRACE',
         ],
       }],
       ['restrict_webrtc_logging==1', {
         'defines': ['WEBRTC_RESTRICT_LOGGING',],
       }],
       ['build_with_mozilla==1', {
         'defines': [
           # Changes settings for Mozilla build.