Skip to content

Commit 249f6e2

Browse files
committed
Add flutter.log to default error submitter
1 parent 668e56b commit 249f6e2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/io/flutter/FlutterErrorReportSubmitter.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.ide.plugins.IdeaPluginDescriptor;
1010
import com.intellij.ide.plugins.PluginManagerCore;
1111
import com.intellij.ide.scratch.ScratchRootType;
12+
import com.intellij.openapi.application.PathManager;
1213
import com.intellij.openapi.actionSystem.DataContext;
1314
import com.intellij.openapi.application.ApplicationInfo;
1415
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
@@ -26,10 +27,13 @@
2627
import org.jetbrains.annotations.Nullable;
2728

2829
import java.awt.*;
30+
import java.io.File;
2931
import java.io.ByteArrayOutputStream;
3032
import java.io.IOException;
3133
import java.io.InputStream;
3234
import java.nio.charset.StandardCharsets;
35+
import java.nio.file.Files;
36+
import java.util.List;
3337
import java.util.concurrent.TimeUnit;
3438

3539
import static com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT;
@@ -176,6 +180,29 @@ public boolean submit(@NotNull IdeaLoggingEvent @NotNull [] events,
176180
builder.append("\n");
177181
}
178182

183+
builder.append("## Flutter log\n\n");
184+
builder.append("```\n");
185+
try {
186+
final String logPath = PathManager.getLogPath();
187+
final File logFile = new File(logPath, "flutter.log");
188+
if (logFile.exists()) {
189+
final List<String> lines = Files.readAllLines(logFile.toPath(), StandardCharsets.UTF_8);
190+
final int count = 200;
191+
final int start = Math.max(0, lines.size() - count);
192+
if (start > 0) {
193+
builder.append("...\n");
194+
}
195+
for (int i = start; i < lines.size(); i++) {
196+
builder.append(lines.get(i)).append("\n");
197+
}
198+
} else {
199+
builder.append("(flutter.log not found)\n");
200+
}
201+
} catch (Exception ex) {
202+
builder.append("(exception trying to read log: ").append(ex.getMessage()).append(")\n");
203+
}
204+
builder.append("```\n\n");
205+
179206
final String text = builder.toString().trim() + "\n";
180207

181208
// Create scratch file.

0 commit comments

Comments
 (0)