diff --git a/src/io/flutter/FlutterUtils.java b/src/io/flutter/FlutterUtils.java index 71b3c9d28..e6753bede 100644 --- a/src/io/flutter/FlutterUtils.java +++ b/src/io/flutter/FlutterUtils.java @@ -111,10 +111,36 @@ public static boolean isAndroidStudio() { } } + public static void info(@NotNull Logger logger, @NotNull Exception e) { + info(logger, e, false); + } + + public static void info(@NotNull Logger logger, @NotNull Exception e, boolean sanitizePaths) { + if (sanitizePaths && FlutterSettings.getInstance().isFilePathLoggingEnabled()) { + logger.info(e); + } else { + logger.info(e.toString()); + } + } + + public static void warn(@NotNull Logger logger, @NotNull Exception e) { + warn(logger, e, false); + } + + public static void warn(@NotNull Logger logger, @NotNull Exception e, boolean sanitizePaths) { + if (sanitizePaths && FlutterSettings.getInstance().isFilePathLoggingEnabled()) { + logger.warn(e); + } else { + logger.warn(e.toString()); + } + } + /** * Write a warning message to the IntelliJ log. *

* This is separate from LOG.warn() to allow us to decorate the behavior. + * + * This method is deprecated (as we are not decorating this behavior anywhere). */ public static void warn(@NotNull Logger logger, @NotNull Throwable t) { logger.warn(t); @@ -124,6 +150,8 @@ public static void warn(@NotNull Logger logger, @NotNull Throwable t) { * Write a warning message to the IntelliJ log. *

* This is separate from LOG.warn() to allow us to decorate the behavior. + * + * This method is deprecated (as we are not decorating this behavior anywhere). */ public static void warn(@NotNull Logger logger, @NotNull String message) { logger.warn(message); @@ -133,6 +161,8 @@ public static void warn(@NotNull Logger logger, @NotNull String message) { * Write a warning message to the IntelliJ log. *

* This is separate from LOG.warn() to allow us to decorate the behavior. + * + * This method is deprecated (as we are not decorating this behavior anywhere). */ public static void warn(@NotNull Logger logger, @NotNull String message, @NotNull Throwable t) { logger.warn(message, t); diff --git a/src/io/flutter/run/LaunchState.java b/src/io/flutter/run/LaunchState.java index 308836cf2..e94766035 100644 --- a/src/io/flutter/run/LaunchState.java +++ b/src/io/flutter/run/LaunchState.java @@ -45,6 +45,7 @@ import io.flutter.FlutterConstants; import io.flutter.FlutterUtils; import io.flutter.dart.DartPlugin; +import io.flutter.logging.PluginLogger; import io.flutter.run.bazel.BazelRunConfig; import io.flutter.run.common.RunMode; import io.flutter.run.daemon.DaemonConsoleView; @@ -180,7 +181,7 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws } } catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) { - LOG.info(e); + FlutterUtils.info(LOG, e, true); } return descriptor; @@ -401,7 +402,7 @@ protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNul app.shutdownAsync().get(); } catch (InterruptedException | java.util.concurrent.ExecutionException e) { - FlutterUtils.warn(LOG, e); + FlutterUtils.warn(LOG, e, true); } return launchState.launch(env); } @@ -458,5 +459,5 @@ public static ProcessHandler getRunningAppProcess(@NotNull RunConfig config) { private static final Key FLUTTER_RUN_CONFIG_KEY = new Key<>("FLUTTER_RUN_CONFIG_KEY"); - private static final @NotNull Logger LOG = Logger.getInstance(LaunchState.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(LaunchState.class); } diff --git a/src/io/flutter/run/SdkFields.java b/src/io/flutter/run/SdkFields.java index d678126da..d7465402f 100644 --- a/src/io/flutter/run/SdkFields.java +++ b/src/io/flutter/run/SdkFields.java @@ -19,7 +19,9 @@ import com.jetbrains.lang.dart.sdk.DartConfigurable; import com.jetbrains.lang.dart.sdk.DartSdk; import io.flutter.FlutterBundle; +import io.flutter.FlutterUtils; import io.flutter.dart.DartPlugin; +import io.flutter.logging.PluginLogger; import io.flutter.pub.PubRoot; import io.flutter.pub.PubRootCache; import io.flutter.run.common.RunMode; @@ -40,7 +42,7 @@ * Fields used when launching an app using the Flutter SDK (non-bazel). */ public class SdkFields { - private static final @NotNull Logger LOG = Logger.getInstance(SdkFields.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(SdkFields.class); private @Nullable String filePath; private @Nullable String buildFlavor; private @Nullable String additionalArgs; @@ -231,7 +233,7 @@ public GeneralCommandLine createFlutterSdkRunCommand( args = ArrayUtil.append(args, "--devtools-server-address=http://" + instance.host() + ":" + instance.port()); } catch (Exception e) { - LOG.info(e); + FlutterUtils.warn(LOG, e, true); } command = flutterSdk.flutterRun(root, main.getFile(), device, runMode, flutterLaunchMode, project, args); final GeneralCommandLine commandLine = command.createGeneralCommandLine(project);