Bug 1573304 - Add GeckoRuntimeSettings.debugLogging() function to control logging r=geckoview-reviewers,agi,snorp
authorRandall E. Barker <rbarker@mozilla.com>
Wed, 14 Aug 2019 00:19:45 +0000
changeset 487844 84f5ba0567105af5c146924b1e519f1e0b998ea8
parent 487843 3739f098ffb3931d265f994d6b1202678f91e5dd
child 487845 bf154b3330d2fc26f5a5f1e354c2d6cdfc29ce57
push id92487
push userrbarker@mozilla.com
push dateWed, 14 Aug 2019 00:20:30 +0000
treeherderautoland@84f5ba056710 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, agi, snorp
bugs1573304
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1573304 - Add GeckoRuntimeSettings.debugLogging() function to control logging r=geckoview-reviewers,agi,snorp Differential Revision: https://phabricator.services.mozilla.com/D41647
mobile/android/geckoview/api.txt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -380,16 +380,17 @@ package org.mozilla.geckoview {
     ctor public Builder();
     method @NonNull public GeckoRuntimeSettings.Builder arguments(@NonNull String[]);
     method @NonNull public GeckoRuntimeSettings.Builder automaticFontSizeAdjustment(boolean);
     method @NonNull public GeckoRuntimeSettings.Builder autoplayDefault(int);
     method @NonNull public GeckoRuntimeSettings.Builder configFilePath(@Nullable String);
     method @NonNull public GeckoRuntimeSettings.Builder consoleOutput(boolean);
     method @NonNull public GeckoRuntimeSettings.Builder contentBlocking(@NonNull ContentBlocking.Settings);
     method @NonNull public GeckoRuntimeSettings.Builder crashHandler(@Nullable Class<?>);
+    method @NonNull public GeckoRuntimeSettings.Builder debugLogging(boolean);
     method @NonNull public GeckoRuntimeSettings.Builder displayDensityOverride(float);
     method @NonNull public GeckoRuntimeSettings.Builder displayDpiOverride(int);
     method @NonNull public GeckoRuntimeSettings.Builder doubleTapZoomingEnabled(boolean);
     method @NonNull public GeckoRuntimeSettings.Builder extras(@NonNull Bundle);
     method @NonNull public GeckoRuntimeSettings.Builder fontInflation(boolean);
     method @NonNull public GeckoRuntimeSettings.Builder fontSizeFactor(float);
     method @NonNull public GeckoRuntimeSettings.Builder glMsaaLevel(int);
     method @NonNull public GeckoRuntimeSettings.Builder inputAutoZoomEnabled(boolean);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoRuntimeSettings.java
@@ -385,16 +385,30 @@ public final class GeckoRuntimeSettings 
          * @return The builder instance.
          */
         public @NonNull Builder telemetryDelegate(
                 final @NonNull RuntimeTelemetry.Delegate delegate) {
             getSettings().mTelemetryProxy = new RuntimeTelemetry.Proxy(delegate);
             getSettings().mTelemetryEnabled.set(true);
             return this;
         }
+
+        /**
+         * Enables GeckoView and Gecko Logging.
+         * Logging is on by default. Does not control all logging in Gecko.
+         * Logging done in Java code must be stripped out at build time.
+         *
+         * @param enable True if logging is enabled.
+         * @return This Builder instance.
+         */
+        public @NonNull Builder debugLogging(final boolean enable) {
+            getSettings().mConsoleServiceToLogcat.set(enable);
+            getSettings().mGeckoViewLogLevel.set(enable ? "Debug" : "Fatal");
+            return this;
+        }
     }
 
     private GeckoRuntime mRuntime;
     /* package */ boolean mUseContentProcess;
     /* package */ String[] mArgs;
     /* package */ Bundle mExtras;
     /* package */ String mConfigFilePath;
 
@@ -423,16 +437,20 @@ public final class GeckoRuntimeSettings 
     /* package */ final Pref<Boolean> mInputAutoZoom = new Pref<>(
             "formhelper.autozoom", true);
     /* package */ final Pref<Boolean> mDoubleTapZooming = new Pref<>(
             "apz.allow_double_tap_zooming", true);
     /* package */ final Pref<Integer> mGlMsaaLevel = new Pref<>(
             "gl.msaa-level", 0);
     /* package */ final Pref<Boolean> mTelemetryEnabled = new Pref<>(
             "toolkit.telemetry.geckoview.streaming", false);
+    /* package */ final Pref<String> mGeckoViewLogLevel = new Pref<>(
+            "geckoview.logging", "Debug");
+    /* package */ final Pref<Boolean> mConsoleServiceToLogcat = new Pref<>(
+            "consoleservice.logcat", true);
 
     /* package */ boolean mDebugPause;
     /* package */ boolean mUseMaxScreenDepth;
     /* package */ float mDisplayDensityOverride = -1.0f;
     /* package */ int mDisplayDpiOverride;
     /* package */ int mScreenWidthOverride;
     /* package */ int mScreenHeightOverride;
     /* package */ Class<? extends Service> mCrashHandler;
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -528,17 +528,17 @@ public class GeckoSession implements Par
                 }
             }
 
             @Override
             public void handleMessage(final NavigationDelegate delegate,
                                       final String event,
                                       final GeckoBundle message,
                                       final EventCallback callback) {
-                Log.i(LOGTAG, "handleMessage " + event + " uri=" + message.getString("uri"));
+                Log.d(LOGTAG, "handleMessage " + event + " uri=" + message.getString("uri"));
                 if ("GeckoView:LocationChange".equals(event)) {
                     if (message.getBoolean("isTopLevel")) {
                         delegate.onLocationChange(GeckoSession.this,
                                                   message.getString("uri"));
                     }
                     delegate.onCanGoBack(GeckoSession.this,
                                          message.getBoolean("canGoBack"));
                     delegate.onCanGoForward(GeckoSession.this,
@@ -649,17 +649,17 @@ public class GeckoSession implements Par
                 "GeckoView:StateUpdated"
             }
         ) {
             @Override
             public void handleMessage(final ProgressDelegate delegate,
                                       final String event,
                                       final GeckoBundle message,
                                       final EventCallback callback) {
-                Log.i(LOGTAG, "handleMessage " + event + " uri=" + message.getString("uri"));
+                Log.d(LOGTAG, "handleMessage " + event + " uri=" + message.getString("uri"));
                 if ("GeckoView:PageStart".equals(event)) {
                     delegate.onPageStart(GeckoSession.this,
                                          message.getString("uri"));
                 } else if ("GeckoView:PageStop".equals(event)) {
                     delegate.onPageStop(GeckoSession.this,
                                         message.getBoolean("success"));
                 } else if ("GeckoView:ProgressChanged".equals(event)) {
                     delegate.onProgressChange(GeckoSession.this,
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
@@ -37,30 +37,33 @@ exclude: true
   ([bug 1571088]({{bugzilla}}1571088))
 - Complete rewrite of [`PromptDelegate`][70.11].
   ([bug 1499394]({{bugzilla}}1499394))
 - Added [`RuntimeTelemetry.Delegate`][70.12] that receives streaming telemetry
   data from GeckoView.
   ([bug 1566367]({{bugzilla}}1566367))
 - Updated [`ContentBlocking`][70.13] to better report blocked and allowed ETP events.
   ([bug 1567268]({{bugzilla}}1567268))
+- Added API for controlling Gecko logging [`GeckoRuntimeSettings.debugLogging`][70.14]
+  ([bug 1573304]({{bugzilla}}1573304))
 
 [70.1]: {{javadoc_uri}}/GeckoSessionSettings.Builder.html#contextId-java.lang.String-
 [70.2]: {{javadoc_uri}}/StorageController.html#clearDataForSessionContext-java.lang.String-
 [70.3]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-java.io.File-java.io.File-java.lang.String-
 [70.4]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-java.io.File-java.util.Map-java.lang.String-
 [70.5]: {{javadoc_uri}}/GeckoView.html
 [70.6]: {{javadoc_uri}}/GeckoSession.html
 [70.7]: {{javadoc_uri}}/GeckoSession.PromptDelegate.html#CAPTURE_TYPE_NONE
 [70.8]: {{javadoc_uri}}/GeckoSession.html#loadUri-java.lang.String-org.mozilla.geckoview.GeckoSession-int-
 [70.9]: {{javadoc_uri}}/GeckoSession.PromptDelegate.html#onFilePrompt-org.mozilla.geckoview.GeckoSession-java.lang.String-int-java.lang.String:A-int-org.mozilla.geckoview.GeckoSession.PromptDelegate.FileCallback-
 [70.10]: {{javadoc_uri}}/GeckoView.html#setSession-org.mozilla.geckoview.GeckoSession-
 [70.11]: {{javadoc_uri}}/GeckoSession.PromptDelegate.html
 [70.12]: {{javadoc_uri}}/RuntimeTelemetry.Delegate.html
 [70.13]: {{javadoc_uri}}/ContentBlocking.html
+[70.14]: {{javadoc_uri}}/GeckoRuntimeSettings.Builder.html#debugLogging-boolean-
 
 ## v69
 - Modified behavior of ['setAutomaticFontSizeAdjustment'][69.1] so that it no 
   longer has any effect on ['setFontInflationEnabled'][69.2]
 - Add [GeckoSession.LOAD_FLAGS_FORCE_ALLOW_DATA_URI][69.14]
 - Added [`GeckoResult.accept`][69.3] for consuming a result without
   transforming it.
 - [`GeckoSession.setMessageDelegate`][69.13] callers must now specify the
@@ -303,9 +306,9 @@ exclude: true
 [65.19]: {{javadoc_uri}}/GeckoSession.NavigationDelegate.LoadRequest.html#isRedirect
 [65.20]: {{javadoc_uri}}/GeckoSession.html#LOAD_FLAGS_BYPASS_CLASSIFIER    
 [65.21]: {{javadoc_uri}}/GeckoSession.ContentDelegate.ContextElement.html
 [65.22]: {{javadoc_uri}}/GeckoSession.ContentDelegate.html#onContextMenu-org.mozilla.geckoview.GeckoSession-int-int-org.mozilla.geckoview.GeckoSession.ContentDelegate.ContextElement-
 [65.23]: {{javadoc_uri}}/GeckoSession.FinderResult.html
 [65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
 [65.25]: {{javadoc_uri}}/GeckoResult.html
 
-[api-version]: 1929f5739623cec70ce9bad19837a4f21604488e
+[api-version]: 99204a5c93667e6d440e55d5d330d01cf4e8783f