commit 6650ab8589f85c1a52664fe64dd13f33a625209b
parent 5fd3a2ec1e73cd2eb5d7029227b2e05a00ba9115
Author: Narcis Beleuzu <nbeleuzu@mozilla.com>
Date: Wed, 22 Oct 2025 15:40:10 +0300
Revert "Bug 1994474 - Part 2. Use MOZ_LOG for GeckoEditable on Nightly. r=geckoview-reviewers,tcampbell" for Lint failure on MozLog.java
This reverts commit 97f5d96228490045d297a2dcc580f79cba76603f.
This reverts commit 5bb2705578cd0477b8310cce793b53b1199382e8.
Diffstat:
8 files changed, 26 insertions(+), 164 deletions(-)
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/MozLog.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/MozLog.java
@@ -1,52 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-package org.mozilla.gecko;
-
-import org.mozilla.gecko.annotation.WrapForJNI;
-
-public class MozLog {
- private static final String LOG_TAG = "MozLog";
-
- public static final int LOG_LEVEL_DISABLE = 0;
- public static final int LOG_LEVEL_ERROR = 1;
- public static final int LOG_LEVEL_WARNING = 2;
- public static final int LOG_LEVEL_INFO = 3;
- public static final int LOG_LEVEL_DEBUG = 4;
- public static final int LOG_LEVEL_VERBOSE = 5;
-
- @WrapForJNI(stubName = "Print")
- private static native void printNative(String name, int level, String message);
-
- public static void print(String name, int level, String message) {
- if (GeckoThread.isRunning()) {
- printNative(name, level, message);
- return;
- }
-
- GeckoThread.queueNativeCall(
- MozLog.class, "printNative", String.class, name, level, String.class, message);
- }
-
- public static void d(final String name, final String message) {
- print(name, LOG_LEVEL_DEBUG, message);
- }
-
- public static void e(final String name, final String message) {
- print(name, LOG_LEVEL_ERROR, message);
- }
-
- public static void i(final String name, final String message) {
- print(name, LOG_LEVEL_INFO, message);
- }
-
- public static void v(final String name, final String message) {
- print(name, LOG_LEVEL_VERBOSE, message);
- }
-
- public static void w(final String name, final String message) {
- print(name, LOG_LEVEL_WARNING, message);
- }
-}
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
@@ -48,7 +48,6 @@ import org.mozilla.gecko.GeckoEditableChild;
import org.mozilla.gecko.IGeckoEditableChild;
import org.mozilla.gecko.IGeckoEditableParent;
import org.mozilla.gecko.InputMethods;
-import org.mozilla.gecko.MozLog;
import org.mozilla.gecko.util.GeckoBundle;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.ThreadUtils.AssertBehavior;
@@ -64,10 +63,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
implements InvocationHandler, Editable, SessionTextInput.EditableClient {
private static final boolean DEBUG = false;
- private static final boolean LOGGING = BuildConfig.NIGHTLY_BUILD;
private static final String LOGTAG = "GeckoEditable";
- private static final String MOZLOGTAG = "IMEHandler";
-
private static final long DISMISS_VKB_DELAY_MS = 100;
// Filters to implement Editable's filtering functionality
@@ -581,11 +577,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
private void icOfferAction(final Action action) {
if (DEBUG) {
assertOnIcThread();
- }
- if (LOGGING) {
- final StringBuilder sb = new StringBuilder("offer: Action(");
- sb.append(getConstantName(Action.class, "TYPE_", action.mType)).append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ Log.d(LOGTAG, "offer: Action(" + getConstantName(Action.class, "TYPE_", action.mType) + ")");
}
switch (action.mType) {
@@ -960,10 +952,10 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
throws RemoteException {
if (DEBUG) {
assertOnIcThread();
- }
- if (LOGGING) {
final StringBuilder sb = new StringBuilder("icSendComposition(");
- debugAppend(sb, text)
+ sb.append("\"")
+ .append(text)
+ .append("\"")
.append(", range = ")
.append(composingStart)
.append("-")
@@ -973,7 +965,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
.append("-")
.append(selEnd)
.append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ Log.d(LOGTAG, sb.toString());
}
if (selEnd >= composingStart && selEnd <= composingEnd) {
@@ -1010,14 +1002,8 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
}
final CharacterStyle[] styleSpans = text.getSpans(rangeStart, rangeEnd, CharacterStyle.class);
- if (LOGGING) {
- final StringBuilder sb = new StringBuilder(" found ");
- sb.append(styleSpans.length)
- .append(" spans @ ")
- .append(rangeStart)
- .append("-")
- .append(rangeEnd);
- MozLog.d(MOZLOGTAG, sb.toString());
+ if (DEBUG) {
+ Log.d(LOGTAG, " found " + styleSpans.length + " spans @ " + rangeStart + "-" + rangeEnd);
}
if (styleSpans.length == 0) {
@@ -1077,16 +1063,17 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
rangeLineColor);
rangeStart = rangeEnd;
- if (LOGGING) {
- final StringBuilder sb = new StringBuilder(" added ");
- sb.append(rangeType)
- .append(" : ")
- .append(Integer.toHexString(rangeStyles))
- .append(" : ")
- .append(Integer.toHexString(rangeForeColor))
- .append(" : ")
- .append(Integer.toHexString(rangeBackColor));
- MozLog.d(MOZLOGTAG, sb.toString());
+ if (DEBUG) {
+ Log.d(
+ LOGTAG,
+ " added "
+ + rangeType
+ + " : "
+ + Integer.toHexString(rangeStyles)
+ + " : "
+ + Integer.toHexString(rangeForeColor)
+ + " : "
+ + Integer.toHexString(rangeBackColor));
}
} while (rangeStart < composingEnd);
}
@@ -1132,11 +1119,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
private void sendKeyEvent(final @NonNull KeyEvent event, final int action, final int metaState) {
if (DEBUG) {
assertOnIcThread();
- }
- if (LOGGING) {
- final StringBuilder sb = new StringBuilder("sendKeyEvent(");
- sb.append(event).append(", ").append(action).append(", ").append(metaState).append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ Log.d(LOGTAG, "sendKeyEvent(" + event + ", " + action + ", " + metaState + ")");
}
/*
We are actually sending two events to Gecko here,
@@ -1459,10 +1442,8 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
Log.w(LOGTAG, "Mismatched reply");
return;
}
- if (LOGGING) {
- final StringBuilder sb = new StringBuilder("reply: Action(");
- sb.append(getConstantName(Action.class, "TYPE_", action.mType)).append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ if (DEBUG) {
+ Log.d(LOGTAG, "reply: Action(" + getConstantName(Action.class, "TYPE_", action.mType) + ")");
}
switch (action.mType) {
case Action.TYPE_REPLACE_TEXT:
@@ -2097,7 +2078,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
public void onSelectionChange(
final IBinder token, final int start, final int end, final boolean causedOnlyByComposition) {
// On Gecko or binder thread.
- if (LOGGING) {
+ if (DEBUG) {
final StringBuilder sb = new StringBuilder("onSelectionChange(");
sb.append(start)
.append(", ")
@@ -2105,7 +2086,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
.append(", ")
.append(causedOnlyByComposition)
.append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ Log.d(LOGTAG, sb.toString());
}
if (!binderCheckToken(token, /* allowNull */ false)) {
@@ -2161,7 +2142,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
final int unboundedOldEnd,
final boolean causedOnlyByComposition) {
// On Gecko or binder thread.
- if (LOGGING) {
+ if (DEBUG) {
final StringBuilder sb = new StringBuilder("onTextChange(");
debugAppend(sb, text)
.append(", ")
@@ -2169,7 +2150,7 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
.append(", ")
.append(unboundedOldEnd)
.append(")");
- MozLog.d(MOZLOGTAG, sb.toString());
+ Log.d(LOGTAG, sb.toString());
}
if (!binderCheckToken(token, /* allowNull */ false)) {
diff --git a/widget/android/GeckoEditableSupport.cpp b/widget/android/GeckoEditableSupport.cpp
@@ -36,7 +36,7 @@
#include <android/log.h>
#ifdef NIGHTLY_BUILD
-static mozilla::LazyLogModule sGeckoEditableSupportLog("IMEHandler");
+static mozilla::LazyLogModule sGeckoEditableSupportLog("GeckoEditableSupport");
# define ALOGIME(...) \
MOZ_LOG(sGeckoEditableSupportLog, LogLevel::Debug, (__VA_ARGS__))
#else
diff --git a/widget/android/MozLogSupport.cpp b/widget/android/MozLogSupport.cpp
@@ -1,23 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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 "MozLogSupport.h"
-#include "mozilla/Logging.h"
-
-namespace mozilla::widget {
-
-// staitc
-void MozLogSupport::Print(jni::String::Param aName, int32_t aLogLevel,
- jni::String::Param aMessage) {
- LogModule* logModule = LogModule::Get(aName->ToCString().get());
- LogLevel logLevel = ToLogLevel(aLogLevel);
- if (!MOZ_LOG_TEST(logModule, logLevel)) {
- return; // Don't log if the level is not enabled.
- }
-
- MOZ_LOG(logModule, logLevel, ("%s", aMessage->ToCString().get()));
-}
-
-} // namespace mozilla::widget
diff --git a/widget/android/MozLogSupport.h b/widget/android/MozLogSupport.h
@@ -1,21 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-#ifndef MozLogSupport_h__
-#define MozLogSupport_h__
-
-#include "mozilla/java/MozLogNatives.h"
-
-namespace mozilla::widget {
-
-class MozLogSupport final : public java::MozLog::Natives<MozLogSupport> {
- public:
- static void Print(mozilla::jni::String::Param aName, int32_t aLogLevel,
- mozilla::jni::String::Param aMessage);
-};
-
-} // namespace mozilla::widget
-
-#endif
diff --git a/widget/android/moz.build b/widget/android/moz.build
@@ -66,7 +66,6 @@ classes_with_WrapForJNI = [
"Image",
"ImageDecoder",
"MediaDrmProxy",
- "MozLog",
"PanZoomController",
"Sample",
"SampleBuffer",
@@ -144,7 +143,6 @@ UNIFIED_SOURCES += [
"GfxInfo.cpp",
"ImageDecoderSupport.cpp",
"InProcessAndroidCompositorWidget.cpp",
- "MozLogSupport.cpp",
"nsAppShell.cpp",
"nsClipboard.cpp",
"nsDeviceContextAndroid.cpp",
diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp
@@ -79,7 +79,6 @@
#include "ScreenHelperAndroid.h"
#include "WebExecutorSupport.h"
#include "Base64UtilsSupport.h"
-#include "MozLogSupport.h"
#ifdef DEBUG_ANDROID_EVENTS
# define EVLOG(args...) ALOG(args)
@@ -435,7 +434,6 @@ nsAppShell::nsAppShell()
GeckoThreadSupport::Init();
GeckoAppShellSupport::Init();
XPCOMEventTargetWrapper::Init();
- mozilla::widget::MozLogSupport::Init();
if (XRE_IsGPUProcess()) {
mozilla::gl::AndroidSurfaceTexture::Init();
@@ -465,7 +463,6 @@ nsAppShell::nsAppShell()
mozilla::widget::Base64UtilsSupport::Init();
nsWindow::InitNatives();
mozilla::gl::AndroidSurfaceTexture::Init();
- mozilla::widget::MozLogSupport::Init();
java::GeckoThread::SetState(java::GeckoThread::State::JNI_READY());
diff --git a/xpcom/docs/logging.rst b/xpcom/docs/logging.rst
@@ -557,24 +557,6 @@ So that ``console.shouldLog()`` only consider the level set by
logger.debug("some debug info");
-Logging from Java
-+++++++++++++++++
-
-In GeckoView, the Java code can log messages using the `org.mozilla.gecko.MozLog` class.
-
-.. code-block:: java
-
- import org.mozilla.gecko.MozLog;
-
- public class Example {
- public void doStuff() {
- final String MODULE = "GeckoSample";
- MozLog.d(MODULE, "Doing stuff");
- MozLog.w(MODULE, "Warning");
- MozLog.e(MODULE, "Error happened");
- }
- }
-
Logging web page errors and warnings
++++++++++++++++++++++++++++++++++++