|
9 | 9 | import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
10 | 10 | import com.intellij.ide.plugins.PluginManagerCore;
|
11 | 11 | import com.intellij.ide.scratch.ScratchRootType;
|
| 12 | +import com.intellij.openapi.application.PathManager; |
12 | 13 | import com.intellij.openapi.actionSystem.DataContext;
|
13 | 14 | import com.intellij.openapi.application.ApplicationInfo;
|
14 | 15 | import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
|
|
26 | 27 | import org.jetbrains.annotations.Nullable;
|
27 | 28 |
|
28 | 29 | import java.awt.*;
|
| 30 | +import java.io.File; |
29 | 31 | import java.io.ByteArrayOutputStream;
|
30 | 32 | import java.io.IOException;
|
31 | 33 | import java.io.InputStream;
|
32 | 34 | import java.nio.charset.StandardCharsets;
|
| 35 | +import java.nio.file.Files; |
| 36 | +import java.util.List; |
33 | 37 | import java.util.concurrent.TimeUnit;
|
34 | 38 |
|
35 | 39 | import static com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT;
|
@@ -176,6 +180,29 @@ public boolean submit(@NotNull IdeaLoggingEvent @NotNull [] events,
|
176 | 180 | builder.append("\n");
|
177 | 181 | }
|
178 | 182 |
|
| 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 | + |
179 | 206 | final String text = builder.toString().trim() + "\n";
|
180 | 207 |
|
181 | 208 | // Create scratch file.
|
|
0 commit comments