From 0d1fb89de95f0300b0422e24d0f4e71c1cf6d8b5 Mon Sep 17 00:00:00 2001 From: Helin Shiah Date: Wed, 24 Sep 2025 11:02:56 -0700 Subject: [PATCH] Convert utility classes to use PluginLogger --- src/io/flutter/utils/FileWatch.java | 6 +++--- .../flutter/utils/IconPreviewGenerator.java | 3 ++- src/io/flutter/utils/Refreshable.java | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/io/flutter/utils/FileWatch.java b/src/io/flutter/utils/FileWatch.java index a353770182..282a705feb 100644 --- a/src/io/flutter/utils/FileWatch.java +++ b/src/io/flutter/utils/FileWatch.java @@ -20,7 +20,7 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.util.messages.MessageBusConnection; -import io.flutter.FlutterUtils; +import io.flutter.logging.PluginLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -131,7 +131,7 @@ private void fireEvent() { callback.run(); } catch (Exception e) { - FlutterUtils.warn(LOG, "Uncaught exception in FileWatch callback", e); + LOG.warn("Uncaught exception in FileWatch callback", e); unsubscribe(); // avoid further errors } } @@ -269,5 +269,5 @@ public void after(@NotNull List events) { } } - private static final @NotNull Logger LOG = Logger.getInstance(FileWatch.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(FileWatch.class); } diff --git a/src/io/flutter/utils/IconPreviewGenerator.java b/src/io/flutter/utils/IconPreviewGenerator.java index e3c3081aac..e8fc2dd6b6 100644 --- a/src/io/flutter/utils/IconPreviewGenerator.java +++ b/src/io/flutter/utils/IconPreviewGenerator.java @@ -8,6 +8,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.TripleFunction; import io.flutter.FlutterUtils; +import io.flutter.logging.PluginLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,7 +25,7 @@ @SuppressWarnings("UseJBColor") public class IconPreviewGenerator { - private static final @NotNull Logger LOG = Logger.getInstance(IconPreviewGenerator.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(IconPreviewGenerator.class); @NotNull final String fontFilePath; int iconSize = 16; diff --git a/src/io/flutter/utils/Refreshable.java b/src/io/flutter/utils/Refreshable.java index a93b7ccd8d..47ab636d47 100644 --- a/src/io/flutter/utils/Refreshable.java +++ b/src/io/flutter/utils/Refreshable.java @@ -14,6 +14,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.util.concurrency.AppExecutorUtil; import io.flutter.FlutterUtils; +import io.flutter.logging.PluginLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -122,7 +123,7 @@ T getWhenReady() { refreshDone.get(); } catch (Exception e) { - FlutterUtils.warn(LOG, "Unexpected exception waiting for refresh task to finish", e); + FlutterUtils.warn(LOG, "Unexpected exception waiting for refresh task to finish", e, true); } return getNow(); } @@ -167,7 +168,7 @@ public void refresh(@NotNull Callable callback) { */ public void refresh(@NotNull Callback callback) { if (publisher.isClosing()) { - FlutterUtils.warn(LOG, "attempted to update closed Refreshable"); + LOG.warn("attempted to update closed Refreshable"); return; } schedule.reschedule(new Request<>(this, callback)); @@ -228,7 +229,7 @@ private void runInBackground() { } catch (Exception e) { if (!Objects.equal(e.getMessage(), "expected failure in test")) { - FlutterUtils.warn(LOG, "Callback threw an exception while updating a Refreshable", e); + FlutterUtils.warn(LOG, "Callback threw an exception while updating a Refreshable", e, true); } } finally { @@ -247,7 +248,7 @@ private void runInBackground() { }); } catch (Exception e) { - FlutterUtils.warn(LOG, "Unable to publish a value while updating a Refreshable", e); + FlutterUtils.warn(LOG, "Unable to publish a value while updating a Refreshable", e, true); } } } @@ -257,7 +258,7 @@ private void runInBackground() { } } - private static final @NotNull Logger LOG = Logger.getInstance(Refreshable.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(Refreshable.class); /** * A value indicating whether the Refreshable is being updated or not. @@ -520,7 +521,7 @@ void unpublish(@Nullable T discarded) { unpublishCallback.accept(discarded); } catch (Exception e) { - FlutterUtils.warn(LOG, "An unpublish callback threw an exception while updating a Refreshable", e); + FlutterUtils.warn(LOG, "An unpublish callback threw an exception while updating a Refreshable", e, true); } } @@ -534,7 +535,7 @@ void setState(State newState) { SwingUtilities.invokeAndWait(() -> doSetState(newState)); } catch (Exception e) { - FlutterUtils.warn(LOG, "Unable to change state of Refreshable", e); + FlutterUtils.warn(LOG, "Unable to change state of Refreshable", e, true); } } @@ -552,7 +553,7 @@ private void fireEvent() { } catch (Exception e) { if (!Objects.equal(e.getMessage(), "expected failure in test")) { - FlutterUtils.warn(LOG, "A subscriber to a Refreshable threw an exception", e); + FlutterUtils.warn(LOG, "A subscriber to a Refreshable threw an exception", e, true); } } } @@ -569,7 +570,7 @@ void waitForFirstValue() { initialized.get(); } catch (Exception e) { - FlutterUtils.warn(LOG, "Unexpected exception waiting for Refreshable to initialize", e); + FlutterUtils.warn(LOG, "Unexpected exception waiting for Refreshable to initialize", e, true); } }