Skip to content

Commit 3b889a5

Browse files
committed
[IMP] report recent messages on crash report
1 parent f15a712 commit 3b889a5

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/main/java/com/odoo/odools/forms/CrashReportForm.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class CrashReportForm extends DialogWrapper {
4242
private String logContent;
4343
private String crashInfo;
4444
private String currentConfig;
45+
private final String recentMessages;
4546

46-
public CrashReportForm(Project project, VirtualFile currentFile, String crash_info, String currentConfig, String logs_path) {
47+
public CrashReportForm(Project project, VirtualFile currentFile, String crash_info, String currentConfig, String logs_path, String recentMessages) {
4748
super(project);
4849
this.currentFile = currentFile;
4950
this.logsPath = logs_path;
@@ -52,6 +53,7 @@ public CrashReportForm(Project project, VirtualFile currentFile, String crash_in
5253
if (currentConfig == null) {
5354
this.currentConfig = "Config not found";
5455
}
56+
this.recentMessages = recentMessages;
5557
setTitle("OdooLS Crash Report");
5658
init(); // required!
5759
}
@@ -107,7 +109,7 @@ public void actionPerformed(ActionEvent e) {
107109
}
108110

109111
private void sendReport(VirtualFile currentFile, String currentFileContent, String logsPath) {
110-
String url = "https://iap-services.odoo.com/api/odools/vscode/2/crash_report";
112+
String url = "https://iap-services.odoo.com/api/odools/vscode/3/crash_report";
111113
String json = buildJson(currentFile, currentFileContent, logsPath);
112114
try (HttpClient client = HttpClient.newHttpClient()) {
113115
HttpRequest request = HttpRequest.newBuilder()
@@ -155,7 +157,8 @@ private String buildJson(VirtualFile currentFile, String currentFileContent, Str
155157
"additional_info": "%s",
156158
"version": "%s",
157159
"python_version": "%s",
158-
"configuration": "%s"
160+
"configuration": "%s",
161+
"recent_messages": "%s"
159162
}
160163
}
161164
""".formatted(
@@ -168,7 +171,8 @@ private String buildJson(VirtualFile currentFile, String currentFileContent, Str
168171
escapeForJson(this.tDescr.getText()),
169172
pluginVersion,
170173
"See configuration",
171-
escapeForJson(this.currentConfig)
174+
escapeForJson(this.currentConfig),
175+
escapeForJson(this.recentMessages)
172176
);
173177
}
174178

src/main/kotlin/com/odoo/odools/OdooCustomLsp4jClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class OdooCustomLsp4jClient(val project: Project, handler: LspServerNotification
8080
val widget = statusBar?.getWidget("OdooLspStatusWidget") as? OdooLspStatusWidget
8181
val currentConfig = widget?.getCurrentConfiguration()?.second
8282
if (logs != null) {
83-
CrashReportForm(project, currentFile, params.getCrashInfo(), currentConfig, logs).show()
83+
CrashReportForm(project, currentFile, params.getCrashInfo(), currentConfig,
84+
logs, params.getRecentMessages()).show()
8485
}
8586
}
8687
})

src/main/kotlin/com/odoo/odools/params/DisplayCrashNotificationParams.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ class DisplayCrashNotificationParams {
88

99
private var crashInfo: String
1010
private var pid: Long
11+
private var recentMessages: String
1112

1213
constructor() {
1314
crashInfo = String()
1415
pid = 0
16+
recentMessages = String()
1517
}
1618

17-
constructor(@NonNull crashInfo: String, @NonNull pid: Long) {
19+
constructor(@NonNull crashInfo: String, @NonNull pid: Long, @NonNull recentMessages: String) {
1820
this.crashInfo = Preconditions.checkNotNull<String>(crashInfo, "crashInfo")
1921
this.pid = Preconditions.checkNotNull(pid, "pid")
22+
this.recentMessages = Preconditions.checkNotNull<String>(crashInfo, "recentMessages")
2023
}
2124

2225
@NonNull
@@ -33,10 +36,19 @@ class DisplayCrashNotificationParams {
3336
return this.crashInfo
3437
}
3538

36-
fun setCrashInfo(@NonNull configFile: List<Map<String, Any>>) {
39+
fun setCrashInfo(@NonNull crashInfo: String) {
3740
this.crashInfo = Preconditions.checkNotNull<String>(crashInfo, "crashInfo")
3841
}
3942

43+
@NonNull
44+
fun getRecentMessages(): String {
45+
return this.recentMessages
46+
}
47+
48+
fun setRecentMessages(@NonNull recentMessages: String) {
49+
this.recentMessages = Preconditions.checkNotNull<String>(recentMessages, "recentMessages")
50+
}
51+
4052
override fun toString(): String {
4153
val b = ToStringBuilder(this)
4254
b.add("configFile", this.crashInfo)

0 commit comments

Comments
 (0)