Skip to content

Add flutter.log to default error submitter #8453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/io/flutter/FlutterErrorReportSubmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManagerCore;
import com.intellij.ide.scratch.ScratchRootType;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.diagnostic.ErrorReportSubmitter;
Expand All @@ -26,10 +27,13 @@
import org.jetbrains.annotations.Nullable;

import java.awt.*;
import java.io.File;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.concurrent.TimeUnit;

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

builder.append("## Flutter log\n\n");
builder.append("```\n");
try {
final String logPath = PathManager.getLogPath();
final File logFile = new File(logPath, "flutter.log");
if (logFile.exists()) {
final List<String> lines = Files.readAllLines(logFile.toPath(), StandardCharsets.UTF_8);
final int count = 200;
final int start = Math.max(0, lines.size() - count);
if (start > 0) {
builder.append("...\n");
}
for (int i = start; i < lines.size(); i++) {
builder.append(lines.get(i)).append("\n");
}
} else {
builder.append("(flutter.log not found)\n");
}
} catch (Exception ex) {
builder.append("(exception trying to read log: ").append(ex.getMessage()).append(")\n");
}
builder.append("```\n\n");

final String text = builder.toString().trim() + "\n";

// Create scratch file.
Expand Down