diff --git a/src/io/flutter/run/daemon/DaemonApi.java b/src/io/flutter/run/daemon/DaemonApi.java index 266c42551..8e82772c1 100644 --- a/src/io/flutter/run/daemon/DaemonApi.java +++ b/src/io/flutter/run/daemon/DaemonApi.java @@ -14,6 +14,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import io.flutter.FlutterUtils; +import io.flutter.logging.PluginLogger; import io.flutter.settings.FlutterSettings; import io.flutter.utils.JsonUtils; import io.flutter.utils.StdoutJsonParser; @@ -41,7 +42,7 @@ public class DaemonApi { private static final int STDERR_LINES_TO_KEEP = 100; private static final Gson GSON = new Gson(); - private static final @NotNull Logger LOG = Logger.getInstance(DaemonApi.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonApi.class); @NotNull private final Consumer callback; private final AtomicInteger nextId = new AtomicInteger(); private final Map pending = new LinkedHashMap<>(); @@ -202,7 +203,7 @@ private Command takePending(int id) { cmd = pending.remove(id); } if (cmd == null) { - FlutterUtils.warn(LOG, "received a response for a request that wasn't sent: " + id); + LOG.warn("received a response for a request that wasn't sent: " + id); return null; } return cmd; @@ -287,7 +288,7 @@ public static JsonObject parseAndValidateDaemonEvent(String message) { private static void sendCommand(String json, ProcessHandler handler) { final PrintWriter stdin = getStdin(handler); if (stdin == null) { - FlutterUtils.warn(LOG, "can't write command to Flutter process: " + json); + LOG.warn("can't write command to Flutter process because stdin is null: " + json); return; } stdin.write('['); @@ -299,7 +300,7 @@ private static void sendCommand(String json, ProcessHandler handler) { } if (stdin.checkError()) { - FlutterUtils.warn(LOG, "can't write command to Flutter process: " + json); + LOG.warn("can't write command to Flutter process due to error: " + json); } } @@ -361,7 +362,7 @@ void complete(@Nullable JsonElement result) { done.complete(parseResult.apply(result)); } catch (Exception e) { - FlutterUtils.warn(LOG, "Unable to parse response from Flutter daemon. Command was: " + this, e); + LOG.warn("Unable to parse response from Flutter daemon. Command was: " + this, e); done.completeExceptionally(e); } } diff --git a/src/io/flutter/run/daemon/DaemonConsoleView.java b/src/io/flutter/run/daemon/DaemonConsoleView.java index 3acb8dc99..9aea45c47 100644 --- a/src/io/flutter/run/daemon/DaemonConsoleView.java +++ b/src/io/flutter/run/daemon/DaemonConsoleView.java @@ -18,6 +18,7 @@ import com.intellij.psi.search.ExecutionSearchScopes; import com.intellij.psi.search.GlobalSearchScope; import com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter; +import io.flutter.logging.PluginLogger; import io.flutter.settings.FlutterSettings; import io.flutter.utils.FlutterModuleUtils; import io.flutter.utils.StdoutJsonParser; @@ -27,7 +28,7 @@ * A console view that filters out JSON messages sent in --machine mode. */ public class DaemonConsoleView extends ConsoleViewImpl { - private static final @NotNull Logger LOG = Logger.getInstance(DaemonConsoleView.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonConsoleView.class); /** * Sets up a launcher to use a DaemonConsoleView. diff --git a/src/io/flutter/run/daemon/DaemonEvent.java b/src/io/flutter/run/daemon/DaemonEvent.java index f40b4bb61..73b8fd633 100644 --- a/src/io/flutter/run/daemon/DaemonEvent.java +++ b/src/io/flutter/run/daemon/DaemonEvent.java @@ -11,6 +11,7 @@ import com.google.gson.JsonSyntaxException; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; +import io.flutter.logging.PluginLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -316,5 +317,5 @@ void accept(Listener listener) { } private static final Gson GSON = new Gson(); - private static final @NotNull Logger LOG = Logger.getInstance(DaemonEvent.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonEvent.class); } diff --git a/src/io/flutter/run/daemon/DeviceService.java b/src/io/flutter/run/daemon/DeviceService.java index 69165a769..72d65e90f 100644 --- a/src/io/flutter/run/daemon/DeviceService.java +++ b/src/io/flutter/run/daemon/DeviceService.java @@ -21,6 +21,7 @@ import io.flutter.FlutterUtils; import io.flutter.bazel.WorkspaceCache; import io.flutter.dart.FlutterDartAnalysisServer; +import io.flutter.logging.PluginLogger; import io.flutter.run.FlutterDevice; import io.flutter.sdk.AndroidEmulatorManager; import io.flutter.sdk.FlutterSdkManager; @@ -173,7 +174,7 @@ private void fireChangeEvent() { listener.run(); } catch (Exception e) { - FlutterUtils.warn(LOG, "DeviceDaemon listener threw an exception", e); + FlutterUtils.warn(LOG, "DeviceDaemon listener threw an exception", e, true); } } }); @@ -258,7 +259,7 @@ private DeviceDaemon chooseNextDaemon(Refreshable.Request request) return nextCommand.start(request::isCancelled, this::refreshDeviceSelection, this::daemonStopped); } catch (ExecutionException executionException) { - LOG.info("Error starting up the Flutter device daemon", executionException); + FlutterUtils.info(LOG, "Error starting up the Flutter device daemon", executionException, true); // Couldn't start a new instance; don't shut down any previous instance. return previous; @@ -284,5 +285,5 @@ private DeviceDaemon shutDownDaemon(Refreshable.Request request) { public enum State {INACTIVE, LOADING, READY} - private static final @NotNull Logger LOG = Logger.getInstance(DeviceService.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(DeviceService.class); } diff --git a/src/io/flutter/run/daemon/FlutterApp.java b/src/io/flutter/run/daemon/FlutterApp.java index 8177736e4..c4532d1bf 100644 --- a/src/io/flutter/run/daemon/FlutterApp.java +++ b/src/io/flutter/run/daemon/FlutterApp.java @@ -80,7 +80,7 @@ * A running Flutter app. */ public class FlutterApp implements Disposable { - private static final @NotNull Logger LOG = Logger.getInstance(FlutterApp.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(FlutterApp.class); private static final Key FLUTTER_APP_KEY = new Key<>("FLUTTER_APP_KEY"); private final @NotNull Project myProject; @@ -339,7 +339,7 @@ void setLaunchMode(@Nullable String launchMode) { */ public CompletableFuture performRestartApp(@NotNull String reason) { if (myAppId == null) { - FlutterUtils.warn(LOG, "cannot restart Flutter app because app id is not set"); + LOG.warn("cannot restart Flutter app because app id is not set"); final CompletableFuture result = new CompletableFuture<>(); result.completeExceptionally(new IllegalStateException("cannot restart Flutter app because app id is not set")); @@ -399,7 +399,7 @@ public void cancelHotReloadState(@Nullable State previousState) { */ public CompletableFuture performHotReload(boolean pauseAfterRestart, @NotNull String reason) { if (myAppId == null) { - FlutterUtils.warn(LOG, "cannot reload Flutter app because app id is not set"); + LOG.warn("cannot reload Flutter app because app id is not set"); if (getState() == State.RELOADING) { changeState(State.STARTED); @@ -430,7 +430,7 @@ public CompletableFuture callServiceExtension(String methodName) { public CompletableFuture callServiceExtension(String methodName, Map params) { if (myAppId == null) { - FlutterUtils.warn(LOG, "cannot invoke " + methodName + " on Flutter app because app id is not set"); + LOG.warn("cannot invoke " + methodName + " on Flutter app because app id is not set"); return CompletableFuture.completedFuture(null); }