Skip to content

Commit d784c25

Browse files
authored
Log a message without exception for no file paths (flutter#8534)
In order to centralize checking for the file paths logging enabled setting, I'll continue using the methods in `FlutterUtils`. However, logging any part of an exception can include file paths, so instead, let's log only an informative message when path logging is disabled. Part of flutter#8369
1 parent e2b291b commit d784c25

13 files changed

+22
-30
lines changed

src/io/flutter/FlutterUtils.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,19 @@ public static boolean isAndroidStudio() {
111111
}
112112
}
113113

114-
public static void info(@NotNull Logger logger, @NotNull Exception e) {
115-
info(logger, e, false);
116-
}
117-
118-
public static void info(@NotNull Logger logger, @NotNull Exception e, boolean sanitizePaths) {
114+
public static void info(@NotNull Logger logger, @NotNull String message, @NotNull Exception e, boolean sanitizePaths) {
119115
if (sanitizePaths && FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
120-
logger.info(e);
116+
logger.info(message, e);
121117
} else {
122-
logger.info(e.toString());
118+
logger.info(message);
123119
}
124120
}
125121

126-
public static void warn(@NotNull Logger logger, @NotNull Exception e) {
127-
warn(logger, e, false);
128-
}
129-
130-
public static void warn(@NotNull Logger logger, @NotNull Exception e, boolean sanitizePaths) {
122+
public static void warn(@NotNull Logger logger, @NotNull String message, @NotNull Exception e, boolean sanitizePaths) {
131123
if (sanitizePaths && FlutterSettings.getInstance().isFilePathLoggingEnabled()) {
132-
logger.warn(e);
124+
logger.warn(message, e);
133125
} else {
134-
logger.warn(e.toString());
126+
logger.warn(message);
135127
}
136128
}
137129

src/io/flutter/editor/FlutterColors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public boolean isPrimary() {
5353
colors.load(FlutterUtils.class.getResourceAsStream("/flutter/colors/material.properties"));
5454
}
5555
catch (IOException e) {
56-
FlutterUtils.warn(LOG, e);
56+
FlutterUtils.warn(LOG, "Failed to load colors", e, true);
5757
}
5858

5959
colorToName = new HashMap<>();

src/io/flutter/editor/FlutterCupertinoColors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class FlutterCupertinoColors {
3131
colors.load(FlutterUtils.class.getResourceAsStream("/flutter/colors/cupertino.properties"));
3232
}
3333
catch (IOException e) {
34-
FlutterUtils.warn(LOG, e);
34+
FlutterUtils.warn(LOG, "Failed to load Cupertino colors", e, true);
3535
}
3636

3737
colorToName = new HashMap<>();

src/io/flutter/editor/FlutterCupertinoIcons.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class FlutterCupertinoIcons {
2727
icons.load(FlutterCupertinoIcons.class.getResourceAsStream("/flutter/icons/cupertino.properties"));
2828
}
2929
catch (IOException e) {
30-
FlutterUtils.warn(LOG, e);
30+
FlutterUtils.warn(LOG, "Failed to load cupertino icons", e, true);
3131
}
3232
}
3333

src/io/flutter/editor/FlutterMaterialIcons.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class FlutterMaterialIcons {
2727
icons.load(FlutterMaterialIcons.class.getResourceAsStream("/flutter/icons/material.properties"));
2828
}
2929
catch (IOException e) {
30-
FlutterUtils.warn(LOG, e);
30+
FlutterUtils.warn(LOG, "Failed to load material icons", e, true);
3131
}
3232
}
3333

src/io/flutter/module/FlutterModuleBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public static void addAndroidModuleFromFile(@NotNull Project project,
223223
}
224224
}
225225
catch (ModuleWithNameAlreadyExists | IOException e) {
226-
FlutterUtils.warn(LOG, e);
226+
FlutterUtils.warn(LOG, "Failed to add Android module", e, true);
227227
}
228228
}
229229

src/io/flutter/run/FlutterDebugProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ private static void suppressDebugViews(@Nullable RunnerLayoutUi ui) {
141141
}
142142
}
143143
catch (ProcessCanceledException e) {
144-
FlutterUtils.warn(LOG, e);
144+
FlutterUtils.warn(LOG, "Failed to suppress debug views", e, true);
145145
throw e;
146146
}
147147
}

src/io/flutter/run/LaunchState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
181181
}
182182
}
183183
catch (IllegalAccessException | InvocationTargetException | NoSuchFieldException | NoSuchMethodException e) {
184-
FlutterUtils.info(LOG, e, true);
184+
FlutterUtils.info(LOG, "Error setting display name", e, true);
185185
}
186186

187187
return descriptor;
@@ -402,7 +402,7 @@ protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNul
402402
app.shutdownAsync().get();
403403
}
404404
catch (InterruptedException | java.util.concurrent.ExecutionException e) {
405-
FlutterUtils.warn(LOG, e, true);
405+
FlutterUtils.warn(LOG, "Error while shutting down app", e, true);
406406
}
407407
return launchState.launch(env);
408408
}

src/io/flutter/run/SdkFields.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public GeneralCommandLine createFlutterSdkRunCommand(
233233
args = ArrayUtil.append(args, "--devtools-server-address=http://" + instance.host() + ":" + instance.port());
234234
}
235235
catch (Exception e) {
236-
FlutterUtils.warn(LOG, e, true);
236+
FlutterUtils.warn(LOG, "Error while starting DevTools", e, true);
237237
}
238238
command = flutterSdk.flutterRun(root, main.getFile(), device, runMode, flutterLaunchMode, project, args);
239239
final GeneralCommandLine commandLine = command.createGeneralCommandLine(project);

src/io/flutter/run/SdkRunConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static class RecursiveDeleter extends SimpleFileVisitor<Path> {
103103
Files.delete(file);
104104
}
105105
catch (IOException e) {
106-
FlutterUtils.warn(LOG, e);
106+
FlutterUtils.warn(LOG, "Unable to delete file: " + name, e, true);
107107
// TODO(jacobr): consider aborting.
108108
}
109109
}
@@ -117,7 +117,7 @@ public static class RecursiveDeleter extends SimpleFileVisitor<Path> {
117117

118118
@Override
119119
public @NotNull FileVisitResult visitFileFailed(@NotNull Path file, @NotNull IOException exc) {
120-
FlutterUtils.warn(LOG, exc);
120+
FlutterUtils.warn(LOG, "Unable to visit file", exc, true);
121121
return CONTINUE;
122122
}
123123
}
@@ -187,7 +187,7 @@ public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnviro
187187
Files.writeString(cachedParametersPath, json);
188188
}
189189
catch (IOException e) {
190-
FlutterUtils.warn(LOG, e);
190+
FlutterUtils.warn(LOG, "Unable to delete dill or write params", e, true);
191191
}
192192
}
193193

0 commit comments

Comments
 (0)