Merge pull request #2609 from DeltaNedas/crashlog
more info in crash reports
This commit is contained in:
@@ -45,4 +45,12 @@ public class Version{
|
||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/** get menu version without colors */
|
||||
public static String combined(){
|
||||
if(build == -1){
|
||||
return "custom build";
|
||||
}
|
||||
return (type.equals("official") ? modifier : type) + " build " + build + (revision == 0 ? "" : "." + revision);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,19 +19,33 @@ import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.mods;
|
||||
import static mindustry.Vars.net;
|
||||
|
||||
public class CrashSender{
|
||||
|
||||
public static String createReport(String error){
|
||||
String report = "Oh no, Mindustry crashed!\n";
|
||||
if(mods.list().size == 0){
|
||||
report += "Please report this at https://github.com/Anuken/Mindustry/issues/new?labels=bug&template=bug_report.md\n\n";
|
||||
}
|
||||
return report + "Version: " + Version.combined() + (Vars.headless ? " (Server)" : "") + "\n"
|
||||
+ "OS: " + System.getProperty("os.name") + " x" + (OS.is64Bit ? "64" : "32") + "\n"
|
||||
+ "Java Version: " + System.getProperty("java.version") + "\n"
|
||||
+ "Java Architecture: " + System.getProperty("sun.arch.data.model") + "\n"
|
||||
+ mods.list().size + " Mods: " + mods.list().toString(", ", mod -> mod.name + ":" + mod.meta.version)
|
||||
+ "\n\n" + error;
|
||||
}
|
||||
|
||||
public static void log(Throwable exception){
|
||||
try{
|
||||
Core.settings.getDataDirectory().child("crashes").child("crash_" + System.currentTimeMillis() + ".txt").writeString(Strings.neatError(exception));
|
||||
Core.settings.getDataDirectory().child("crashes").child("crash_" + System.currentTimeMillis() + ".txt")
|
||||
.writeString(createReport(Strings.neatError(exception)));
|
||||
}catch(Throwable ignored){
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(Throwable exception, Cons<File> writeListener){
|
||||
|
||||
try{
|
||||
exception.printStackTrace();
|
||||
|
||||
@@ -70,7 +84,7 @@ public class CrashSender{
|
||||
try{
|
||||
File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + new SimpleDateFormat("MM_dd_yyyy_HH_mm_ss").format(new Date()) + ".txt");
|
||||
new Fi(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs();
|
||||
new Fi(file).writeString(parseException(exception));
|
||||
new Fi(file).writeString(createReport(parseException(exception)));
|
||||
writeListener.get(file);
|
||||
}catch(Throwable e){
|
||||
Log.err("Failed to save local crash report.", e);
|
||||
@@ -130,7 +144,7 @@ public class CrashSender{
|
||||
boolean[] sent = {false};
|
||||
|
||||
Log.info("Sending crash report.");
|
||||
//post to crash report URL
|
||||
//post to crash report URL, exit code indicates send success
|
||||
httpPost(Vars.crashReportURL, value.toJson(OutputType.json), r -> {
|
||||
Log.info("Crash sent successfully.");
|
||||
sent[0] = true;
|
||||
@@ -138,7 +152,7 @@ public class CrashSender{
|
||||
}, t -> {
|
||||
t.printStackTrace();
|
||||
sent[0] = true;
|
||||
System.exit(1);
|
||||
System.exit(-1);
|
||||
});
|
||||
|
||||
//sleep until report is sent
|
||||
|
||||
@@ -73,8 +73,7 @@ public class MenuFragment extends Fragment{
|
||||
}));
|
||||
}
|
||||
|
||||
String versionText = "[#ffffffba]" + ((Version.build == -1) ? "[#fc8140aa]custom build" : (Version.type.equals("official") ? Version.modifier : Version.type) + " build " + Version.build + (Version.revision == 0 ? "" : "." + Version.revision));
|
||||
|
||||
String versionText = ((Version.build == -1) ? "[#fc8140aa]" : "[#ffffffba]") + Version.combined();
|
||||
parent.fill((x, y, w, h) -> {
|
||||
TextureRegion logo = Core.atlas.find("logo");
|
||||
float logoscl = Scl.scl(1);
|
||||
|
||||
Reference in New Issue
Block a user