Skip to content

Commit e2f137e

Browse files
authored
Change classes in io.flutter.run.daemon to use PluginLogger (flutter#8529)
Part of flutter#8369
1 parent 98f04c1 commit e2f137e

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

src/io/flutter/run/daemon/DaemonApi.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.intellij.openapi.diagnostic.Logger;
1515
import com.intellij.openapi.util.Key;
1616
import io.flutter.FlutterUtils;
17+
import io.flutter.logging.PluginLogger;
1718
import io.flutter.settings.FlutterSettings;
1819
import io.flutter.utils.JsonUtils;
1920
import io.flutter.utils.StdoutJsonParser;
@@ -41,7 +42,7 @@ public class DaemonApi {
4142

4243
private static final int STDERR_LINES_TO_KEEP = 100;
4344
private static final Gson GSON = new Gson();
44-
private static final @NotNull Logger LOG = Logger.getInstance(DaemonApi.class);
45+
private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonApi.class);
4546
@NotNull private final Consumer<String> callback;
4647
private final AtomicInteger nextId = new AtomicInteger();
4748
private final Map<Integer, Command> pending = new LinkedHashMap<>();
@@ -202,7 +203,7 @@ private Command takePending(int id) {
202203
cmd = pending.remove(id);
203204
}
204205
if (cmd == null) {
205-
FlutterUtils.warn(LOG, "received a response for a request that wasn't sent: " + id);
206+
LOG.warn("received a response for a request that wasn't sent: " + id);
206207
return null;
207208
}
208209
return cmd;
@@ -287,7 +288,7 @@ public static JsonObject parseAndValidateDaemonEvent(String message) {
287288
private static void sendCommand(String json, ProcessHandler handler) {
288289
final PrintWriter stdin = getStdin(handler);
289290
if (stdin == null) {
290-
FlutterUtils.warn(LOG, "can't write command to Flutter process: " + json);
291+
LOG.warn("can't write command to Flutter process because stdin is null: " + json);
291292
return;
292293
}
293294
stdin.write('[');
@@ -299,7 +300,7 @@ private static void sendCommand(String json, ProcessHandler handler) {
299300
}
300301

301302
if (stdin.checkError()) {
302-
FlutterUtils.warn(LOG, "can't write command to Flutter process: " + json);
303+
LOG.warn("can't write command to Flutter process due to error: " + json);
303304
}
304305
}
305306

@@ -361,7 +362,7 @@ void complete(@Nullable JsonElement result) {
361362
done.complete(parseResult.apply(result));
362363
}
363364
catch (Exception e) {
364-
FlutterUtils.warn(LOG, "Unable to parse response from Flutter daemon. Command was: " + this, e);
365+
LOG.warn("Unable to parse response from Flutter daemon. Command was: " + this, e);
365366
done.completeExceptionally(e);
366367
}
367368
}

src/io/flutter/run/daemon/DaemonConsoleView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.intellij.psi.search.ExecutionSearchScopes;
1919
import com.intellij.psi.search.GlobalSearchScope;
2020
import com.jetbrains.lang.dart.ide.runner.DartRelativePathsConsoleFilter;
21+
import io.flutter.logging.PluginLogger;
2122
import io.flutter.settings.FlutterSettings;
2223
import io.flutter.utils.FlutterModuleUtils;
2324
import io.flutter.utils.StdoutJsonParser;
@@ -27,7 +28,7 @@
2728
* A console view that filters out JSON messages sent in --machine mode.
2829
*/
2930
public class DaemonConsoleView extends ConsoleViewImpl {
30-
private static final @NotNull Logger LOG = Logger.getInstance(DaemonConsoleView.class);
31+
private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonConsoleView.class);
3132

3233
/**
3334
* Sets up a launcher to use a DaemonConsoleView.

src/io/flutter/run/daemon/DaemonEvent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.google.gson.JsonSyntaxException;
1212
import com.intellij.openapi.diagnostic.Logger;
1313
import com.intellij.openapi.util.text.StringUtil;
14+
import io.flutter.logging.PluginLogger;
1415
import org.jetbrains.annotations.NotNull;
1516
import org.jetbrains.annotations.Nullable;
1617

@@ -316,5 +317,5 @@ void accept(Listener listener) {
316317
}
317318

318319
private static final Gson GSON = new Gson();
319-
private static final @NotNull Logger LOG = Logger.getInstance(DaemonEvent.class);
320+
private static final @NotNull Logger LOG = PluginLogger.createLogger(DaemonEvent.class);
320321
}

src/io/flutter/run/daemon/DeviceService.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.flutter.FlutterUtils;
2222
import io.flutter.bazel.WorkspaceCache;
2323
import io.flutter.dart.FlutterDartAnalysisServer;
24+
import io.flutter.logging.PluginLogger;
2425
import io.flutter.run.FlutterDevice;
2526
import io.flutter.sdk.AndroidEmulatorManager;
2627
import io.flutter.sdk.FlutterSdkManager;
@@ -173,7 +174,7 @@ private void fireChangeEvent() {
173174
listener.run();
174175
}
175176
catch (Exception e) {
176-
FlutterUtils.warn(LOG, "DeviceDaemon listener threw an exception", e);
177+
FlutterUtils.warn(LOG, "DeviceDaemon listener threw an exception", e, true);
177178
}
178179
}
179180
});
@@ -258,7 +259,7 @@ private DeviceDaemon chooseNextDaemon(Refreshable.Request<DeviceDaemon> request)
258259
return nextCommand.start(request::isCancelled, this::refreshDeviceSelection, this::daemonStopped);
259260
}
260261
catch (ExecutionException executionException) {
261-
LOG.info("Error starting up the Flutter device daemon", executionException);
262+
FlutterUtils.info(LOG, "Error starting up the Flutter device daemon", executionException, true);
262263

263264
// Couldn't start a new instance; don't shut down any previous instance.
264265
return previous;
@@ -284,5 +285,5 @@ private DeviceDaemon shutDownDaemon(Refreshable.Request<DeviceDaemon> request) {
284285

285286
public enum State {INACTIVE, LOADING, READY}
286287

287-
private static final @NotNull Logger LOG = Logger.getInstance(DeviceService.class);
288+
private static final @NotNull Logger LOG = PluginLogger.createLogger(DeviceService.class);
288289
}

src/io/flutter/run/daemon/FlutterApp.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* A running Flutter app.
8181
*/
8282
public class FlutterApp implements Disposable {
83-
private static final @NotNull Logger LOG = Logger.getInstance(FlutterApp.class);
83+
private static final @NotNull Logger LOG = PluginLogger.createLogger(FlutterApp.class);
8484
private static final Key<FlutterApp> FLUTTER_APP_KEY = new Key<>("FLUTTER_APP_KEY");
8585

8686
private final @NotNull Project myProject;
@@ -339,7 +339,7 @@ void setLaunchMode(@Nullable String launchMode) {
339339
*/
340340
public CompletableFuture<DaemonApi.RestartResult> performRestartApp(@NotNull String reason) {
341341
if (myAppId == null) {
342-
FlutterUtils.warn(LOG, "cannot restart Flutter app because app id is not set");
342+
LOG.warn("cannot restart Flutter app because app id is not set");
343343

344344
final CompletableFuture<DaemonApi.RestartResult> result = new CompletableFuture<>();
345345
result.completeExceptionally(new IllegalStateException("cannot restart Flutter app because app id is not set"));
@@ -399,7 +399,7 @@ public void cancelHotReloadState(@Nullable State previousState) {
399399
*/
400400
public CompletableFuture<DaemonApi.RestartResult> performHotReload(boolean pauseAfterRestart, @NotNull String reason) {
401401
if (myAppId == null) {
402-
FlutterUtils.warn(LOG, "cannot reload Flutter app because app id is not set");
402+
LOG.warn("cannot reload Flutter app because app id is not set");
403403

404404
if (getState() == State.RELOADING) {
405405
changeState(State.STARTED);
@@ -430,7 +430,7 @@ public CompletableFuture<JsonObject> callServiceExtension(String methodName) {
430430

431431
public CompletableFuture<JsonObject> callServiceExtension(String methodName, Map<String, Object> params) {
432432
if (myAppId == null) {
433-
FlutterUtils.warn(LOG, "cannot invoke " + methodName + " on Flutter app because app id is not set");
433+
LOG.warn("cannot invoke " + methodName + " on Flutter app because app id is not set");
434434
return CompletableFuture.completedFuture(null);
435435
}
436436

0 commit comments

Comments
 (0)