Skip to content

Commit f15448e

Browse files
committed
Change DeviceDaemon to use separate log file
1 parent 668e56b commit f15448e

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

src/io/flutter/FlutterUtils.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,6 @@ public static void warn(@NotNull Logger logger, @NotNull Exception e, boolean sa
135135
}
136136
}
137137

138-
/**
139-
* Write a warning message to the IntelliJ log.
140-
* <p>
141-
* This is separate from LOG.warn() to allow us to decorate the behavior.
142-
*
143-
* This method is deprecated (as we are not decorating this behavior anywhere).
144-
*/
145-
public static void warn(@NotNull Logger logger, @NotNull Throwable t) {
146-
logger.warn(t);
147-
}
148-
149138
/**
150139
* Write a warning message to the IntelliJ log.
151140
* <p>

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@
2424
import io.flutter.android.IntelliJAndroidSdk;
2525
import io.flutter.bazel.Workspace;
2626
import io.flutter.bazel.WorkspaceCache;
27+
import io.flutter.logging.PluginLogger;
2728
import io.flutter.run.FlutterDevice;
2829
import io.flutter.sdk.FlutterSdk;
2930
import io.flutter.sdk.FlutterSdkUtil;
31+
import io.flutter.settings.FlutterSettings;
3032
import io.flutter.utils.FlutterModuleUtils;
3133
import io.flutter.utils.MostlySilentColoredProcessHandler;
3234
import io.flutter.utils.OpenApiUtils;
3335
import org.jetbrains.annotations.NotNull;
3436
import org.jetbrains.annotations.Nullable;
3537

3638
import javax.swing.*;
39+
import java.io.File;
3740
import java.nio.charset.StandardCharsets;
3841
import java.util.ArrayList;
3942
import java.util.Comparator;
@@ -114,7 +117,7 @@ boolean needRestart(@NotNull Command next) {
114117
*/
115118
void shutdown() {
116119
if (!process.isProcessTerminated()) {
117-
LOG.info("shutting down Flutter device daemon #" + id + ": " + command);
120+
LOG.info("shutting down Flutter device daemon #" + id + ": " + command.toString(FlutterSettings.getInstance().isFilePathLoggingEnabled()));
118121
}
119122
listener.running.set(false);
120123
process.destroyProcess();
@@ -207,7 +210,7 @@ DeviceDaemon start(Supplier<Boolean> isCancelled,
207210
Consumer<String> processStopped) throws ExecutionException {
208211
final int daemonId = nextDaemonId.incrementAndGet();
209212
//noinspection UnnecessaryToStringCall
210-
LOG.info("starting Flutter device daemon #" + daemonId + ": " + toString());
213+
LOG.info("starting Flutter device daemon #" + daemonId + ": " + toString(FlutterSettings.getInstance().isFilePathLoggingEnabled()));
211214
// The mostly silent process handler reduces CPU usage of the daemon process.
212215
final ProcessHandler process = new MostlySilentColoredProcessHandler(toCommandLine());
213216

@@ -268,7 +271,7 @@ else if (attempts == DeviceDaemon.RESTART_ATTEMPTS_BEFORE_WARNING + 4) {
268271
}
269272
catch (java.util.concurrent.ExecutionException e) {
270273
// This is not a user facing crash - we log (and no devices will be discovered).
271-
FlutterUtils.warn(LOG, e.getCause());
274+
FlutterUtils.warn(LOG, e, true);
272275
}
273276
}
274277
}
@@ -311,8 +314,12 @@ private GeneralCommandLine toCommandLine() {
311314

312315
@Override
313316
public String toString() {
317+
return toString(true);
318+
}
319+
320+
public @NotNull String toString(boolean showFullPath) {
314321
final StringBuilder out = new StringBuilder();
315-
out.append(command);
322+
out.append(showFullPath ? command : command.substring(command.lastIndexOf(File.separatorChar) + 1));
316323
if (!parameters.isEmpty()) {
317324
out.append(' ');
318325
out.append(Joiner.on(' ').join(parameters));
@@ -426,7 +433,7 @@ private static ImmutableList<FlutterDevice> removeDevice(Stream<FlutterDevice> o
426433
}
427434
}
428435

429-
private static final @NotNull Logger LOG = Logger.getInstance(DeviceDaemon.class);
436+
private static final @NotNull Logger LOG = PluginLogger.createLogger(DeviceDaemon.class);
430437

431438
// If the daemon cannot be started, display a modal dialog with hopefully helpful
432439
// instructions on how to fix the problem. This is a big problem; we really do

src/io/flutter/sdk/FlutterSdk.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,7 @@ public PubRoot createFiles(@NotNull VirtualFile baseDir, @Nullable Module module
444444
}
445445
}
446446
catch (InterruptedException e) {
447-
if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
448-
LOG.warn(e);
449-
} else {
450-
LOG.warn(e.toString());
451-
}
447+
FlutterUtils.warn(LOG, e, true);
452448
return null;
453449
}
454450

0 commit comments

Comments
 (0)