Skip to content

Commit 6f3f6b9

Browse files
authored
Convert utility classes to use PluginLogger (flutter#8546)
Part of flutter#8369 `FileWatch` is only used in bazel contexts, so I'm not using the path checking there.
1 parent e97ba7f commit 6f3f6b9

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/io/flutter/utils/FileWatch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
2121
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
2222
import com.intellij.util.messages.MessageBusConnection;
23-
import io.flutter.FlutterUtils;
23+
import io.flutter.logging.PluginLogger;
2424
import org.jetbrains.annotations.NotNull;
2525
import org.jetbrains.annotations.Nullable;
2626

@@ -131,7 +131,7 @@ private void fireEvent() {
131131
callback.run();
132132
}
133133
catch (Exception e) {
134-
FlutterUtils.warn(LOG, "Uncaught exception in FileWatch callback", e);
134+
LOG.warn("Uncaught exception in FileWatch callback", e);
135135
unsubscribe(); // avoid further errors
136136
}
137137
}
@@ -269,5 +269,5 @@ public void after(@NotNull List<? extends VFileEvent> events) {
269269
}
270270
}
271271

272-
private static final @NotNull Logger LOG = Logger.getInstance(FileWatch.class);
272+
private static final @NotNull Logger LOG = PluginLogger.createLogger(FileWatch.class);
273273
}

src/io/flutter/utils/IconPreviewGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.openapi.diagnostic.Logger;
99
import com.intellij.util.TripleFunction;
1010
import io.flutter.FlutterUtils;
11+
import io.flutter.logging.PluginLogger;
1112
import org.jetbrains.annotations.NotNull;
1213
import org.jetbrains.annotations.Nullable;
1314

@@ -24,7 +25,7 @@
2425

2526
@SuppressWarnings("UseJBColor")
2627
public class IconPreviewGenerator {
27-
private static final @NotNull Logger LOG = Logger.getInstance(IconPreviewGenerator.class);
28+
private static final @NotNull Logger LOG = PluginLogger.createLogger(IconPreviewGenerator.class);
2829

2930
@NotNull final String fontFilePath;
3031
int iconSize = 16;

src/io/flutter/utils/Refreshable.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.intellij.openapi.util.Disposer;
1515
import com.intellij.util.concurrency.AppExecutorUtil;
1616
import io.flutter.FlutterUtils;
17+
import io.flutter.logging.PluginLogger;
1718
import org.jetbrains.annotations.NotNull;
1819
import org.jetbrains.annotations.Nullable;
1920

@@ -122,7 +123,7 @@ T getWhenReady() {
122123
refreshDone.get();
123124
}
124125
catch (Exception e) {
125-
FlutterUtils.warn(LOG, "Unexpected exception waiting for refresh task to finish", e);
126+
FlutterUtils.warn(LOG, "Unexpected exception waiting for refresh task to finish", e, true);
126127
}
127128
return getNow();
128129
}
@@ -167,7 +168,7 @@ public void refresh(@NotNull Callable<T> callback) {
167168
*/
168169
public void refresh(@NotNull Callback<T> callback) {
169170
if (publisher.isClosing()) {
170-
FlutterUtils.warn(LOG, "attempted to update closed Refreshable");
171+
LOG.warn("attempted to update closed Refreshable");
171172
return;
172173
}
173174
schedule.reschedule(new Request<>(this, callback));
@@ -228,7 +229,7 @@ private void runInBackground() {
228229
}
229230
catch (Exception e) {
230231
if (!Objects.equal(e.getMessage(), "expected failure in test")) {
231-
FlutterUtils.warn(LOG, "Callback threw an exception while updating a Refreshable", e);
232+
FlutterUtils.warn(LOG, "Callback threw an exception while updating a Refreshable", e, true);
232233
}
233234
}
234235
finally {
@@ -247,7 +248,7 @@ private void runInBackground() {
247248
});
248249
}
249250
catch (Exception e) {
250-
FlutterUtils.warn(LOG, "Unable to publish a value while updating a Refreshable", e);
251+
FlutterUtils.warn(LOG, "Unable to publish a value while updating a Refreshable", e, true);
251252
}
252253
}
253254
}
@@ -257,7 +258,7 @@ private void runInBackground() {
257258
}
258259
}
259260

260-
private static final @NotNull Logger LOG = Logger.getInstance(Refreshable.class);
261+
private static final @NotNull Logger LOG = PluginLogger.createLogger(Refreshable.class);
261262

262263
/**
263264
* A value indicating whether the Refreshable is being updated or not.
@@ -520,7 +521,7 @@ void unpublish(@Nullable T discarded) {
520521
unpublishCallback.accept(discarded);
521522
}
522523
catch (Exception e) {
523-
FlutterUtils.warn(LOG, "An unpublish callback threw an exception while updating a Refreshable", e);
524+
FlutterUtils.warn(LOG, "An unpublish callback threw an exception while updating a Refreshable", e, true);
524525
}
525526
}
526527

@@ -534,7 +535,7 @@ void setState(State newState) {
534535
SwingUtilities.invokeAndWait(() -> doSetState(newState));
535536
}
536537
catch (Exception e) {
537-
FlutterUtils.warn(LOG, "Unable to change state of Refreshable", e);
538+
FlutterUtils.warn(LOG, "Unable to change state of Refreshable", e, true);
538539
}
539540
}
540541

@@ -552,7 +553,7 @@ private void fireEvent() {
552553
}
553554
catch (Exception e) {
554555
if (!Objects.equal(e.getMessage(), "expected failure in test")) {
555-
FlutterUtils.warn(LOG, "A subscriber to a Refreshable threw an exception", e);
556+
FlutterUtils.warn(LOG, "A subscriber to a Refreshable threw an exception", e, true);
556557
}
557558
}
558559
}
@@ -569,7 +570,7 @@ void waitForFirstValue() {
569570
initialized.get();
570571
}
571572
catch (Exception e) {
572-
FlutterUtils.warn(LOG, "Unexpected exception waiting for Refreshable to initialize", e);
573+
FlutterUtils.warn(LOG, "Unexpected exception waiting for Refreshable to initialize", e, true);
573574
}
574575
}
575576

0 commit comments

Comments
 (0)