diff --git a/flutter-idea/src/io/flutter/FlutterBundle.properties b/flutter-idea/src/io/flutter/FlutterBundle.properties index d8b3649c5..cf6104bf9 100644 --- a/flutter-idea/src/io/flutter/FlutterBundle.properties +++ b/flutter-idea/src/io/flutter/FlutterBundle.properties @@ -157,6 +157,8 @@ settings.report.analytics.tooltip=Report anonymized usage information to Google settings.enable.verbose.logging.tooltip=Enables verbose logging (this can be useful for diagnostic purposes). # suppress inspection "UnusedProperty" (used in a `FlutterSettingsConfigurable.form`) settings.enable.logs.preserve.during.hot.reload.and.restart=Preserve console logs during Hot Reload and Hot Restart +settings.enable.file.path.logging=Allow logging of full file paths +settings.enable.file.path.logging.tooltip=Logs full file paths that could show private user information action.new.project.title=New Flutter Project... welcome.new.project.compact=New Flutter Project diff --git a/flutter-idea/src/io/flutter/sdk/FlutterCommand.java b/flutter-idea/src/io/flutter/sdk/FlutterCommand.java index 0a6c6c3fb..7bab6184e 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterCommand.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterCommand.java @@ -19,11 +19,14 @@ import io.flutter.android.IntelliJAndroidSdk; import io.flutter.console.FlutterConsoles; import io.flutter.dart.DartPlugin; +import io.flutter.logging.PluginLogger; +import io.flutter.settings.FlutterSettings; import io.flutter.utils.MostlySilentColoredProcessHandler; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.nio.charset.StandardCharsets; +import java.nio.file.Path; import java.util.*; import java.util.function.Consumer; @@ -31,7 +34,7 @@ * A Flutter command to run, with its arguments. */ public class FlutterCommand { - private static final @NotNull Logger LOG = Logger.getInstance(FlutterCommand.class); + private static final @NotNull Logger LOG = PluginLogger.createLogger(FlutterCommand.class); private static final Set pubRelatedCommands = new HashSet<>( Arrays.asList(Type.PUB_GET, Type.PUB_UPGRADE, Type.PUB_OUTDATED, Type.UPGRADE)); @@ -166,7 +169,7 @@ public String toString() { public ColoredProcessHandler startProcess(boolean sendAnalytics) { try { final GeneralCommandLine commandLine = createGeneralCommandLine(null); - LOG.info(commandLine.toString()); + LOG.info(safeCommandLog(commandLine)); return new ColoredProcessHandler(commandLine); } catch (ExecutionException e) { @@ -194,7 +197,7 @@ public FlutterCommandStartResult startProcess(@Nullable Project project) { final ColoredProcessHandler handler; try { final GeneralCommandLine commandLine = createGeneralCommandLine(project); - LOG.info(commandLine.toString()); + LOG.info(safeCommandLog(commandLine)); handler = new MostlySilentColoredProcessHandler(commandLine); handler.addProcessListener(new ProcessAdapter() { @Override @@ -290,4 +293,14 @@ enum Type { this.subCommand = ImmutableList.copyOf(subCommand); } } + + private @NotNull String safeCommandLog(@NotNull GeneralCommandLine commandLine) { + if (FlutterSettings.getInstance().isFilePathLoggingEnabled()) { + final String fullString = commandLine.toString(); + return fullString != null ? fullString : ""; + } + + final Path path = Path.of(commandLine.getExePath()); + return path.getFileName() + commandLine.getParametersList().toString(); + } } diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form index 804b54ec3..a0305ce49 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form +++ b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.form @@ -59,7 +59,7 @@ - + @@ -85,6 +85,15 @@ + + + + + + + + + diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java index bb4907257..415e6e03d 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java @@ -86,6 +86,7 @@ public class FlutterSettingsConfigurable implements SearchableConfigurable { private JCheckBox myAllowTestsInSourcesRoot; private ActionLink settingsLink; private JCheckBox myEnableLogsPreserveAfterHotReloadOrRestart; + private @NotNull JCheckBox myEnableFilePathLogging; private final @NotNull Project myProject; private final WorkspaceCache workspaceCache; @@ -245,6 +246,10 @@ public boolean isModified() { return true; } + if (settings.isFilePathLoggingEnabled() != myEnableFilePathLogging.isSelected()) { + return true; + } + return settings.isEnableJcefBrowser() != myEnableJcefBrowserCheckBox.isSelected(); } @@ -299,6 +304,7 @@ public void apply() throws ConfigurationException { settings.setAllowTestsInSourcesRoot(myAllowTestsInSourcesRoot.isSelected()); settings.setFontPackages(myFontPackagesTextArea.getText()); settings.setEnableJcefBrowser(myEnableJcefBrowserCheckBox.isSelected()); + settings.setFilePathLoggingEnabled(myEnableFilePathLogging.isSelected()); reset(); // because we rely on remembering initial state checkFontPackages(settings.getFontPackages(), oldFontPackages); @@ -366,6 +372,7 @@ public void reset() { myEnableJcefBrowserCheckBox.setSelected(settings.isEnableJcefBrowser()); myFontPackagesTextArea.setText(settings.getFontPackages()); + myEnableFilePathLogging.setSelected(settings.isFilePathLoggingEnabled()); } private void onVersionChanged() { diff --git a/flutter-idea/src/io/flutter/settings/FlutterSettings.java b/flutter-idea/src/io/flutter/settings/FlutterSettings.java index cb88e4680..4f9d35fb4 100644 --- a/flutter-idea/src/io/flutter/settings/FlutterSettings.java +++ b/flutter-idea/src/io/flutter/settings/FlutterSettings.java @@ -35,6 +35,7 @@ public class FlutterSettings { private static final String showBazelIosRunNotificationKey = "io.flutter.hideBazelIosRunNotification"; private static final String sdkVersionOutdatedWarningAcknowledgedKey = "io.flutter.sdkVersionOutdatedWarningAcknowledged"; private static final String androidStudioBotAcknowledgedKey = "io.flutter.androidStudioBotAcknowledgedKey"; + private static final String enableFilePathLoggingKey = "io.flutter.enableFilePathLogging"; private static @Nullable FlutterSettings testInstance; @@ -261,4 +262,12 @@ public boolean isAndroidStudioBotAcknowledged() { public void setAndroidStudioBotAcknowledgedKey(boolean value) { getPropertiesComponent().setValue(androidStudioBotAcknowledgedKey, value); } + + public boolean isFilePathLoggingEnabled() { + return getPropertiesComponent().getBoolean(enableFilePathLoggingKey, false); + } + + public void setFilePathLoggingEnabled(boolean value) { + getPropertiesComponent().setValue(enableFilePathLoggingKey, value); + } }