Build Hash and Version for error logs in the database

This commit is contained in:
Harmony 2019-05-14 20:39:35 +01:00
parent 3b480db9f6
commit b67fa1b27b
2 changed files with 19 additions and 3 deletions

View File

@ -2,4 +2,8 @@
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('commands.plugins.oldstyle', '0'); INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('commands.plugins.oldstyle', '0');
ALTER TABLE `emulator_errors`
ADD COLUMN `version` varchar(64) NOT NULL AFTER `timestamp`,
ADD COLUMN `build_hash` varchar(64) NOT NULL AFTER `version`;
#END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3 #END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3

View File

@ -11,13 +11,20 @@ import java.sql.SQLException;
public class ErrorLog implements Loggable public class ErrorLog implements Loggable
{ {
public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, type, stacktrace) VALUES (?, ?, ?)"; public final static String insertQuery = "INSERT INTO emulator_errors (timestamp, version, build_hash, type, stacktrace) VALUES (?, ?, ?, ?, ?)";
public final String version;
public final String buildHash;
public final int timeStamp; public final int timeStamp;
public final String type; public final String type;
public final String stackTrace; public final String stackTrace;
public ErrorLog(String type, Throwable e) public ErrorLog(String type, Throwable e)
{ {
this.version = Emulator.version;
this.buildHash = Emulator.version;
this.timeStamp = Emulator.getIntUnixTimestamp(); this.timeStamp = Emulator.getIntUnixTimestamp();
this.type = type; this.type = type;
@ -38,6 +45,9 @@ public class ErrorLog implements Loggable
public ErrorLog(String type, String message) public ErrorLog(String type, String message)
{ {
this.version = Emulator.version;
this.buildHash = Emulator.build;
this.timeStamp = Emulator.getIntUnixTimestamp(); this.timeStamp = Emulator.getIntUnixTimestamp();
this.type = type; this.type = type;
this.stackTrace = message; this.stackTrace = message;
@ -47,8 +57,10 @@ public class ErrorLog implements Loggable
public void log(PreparedStatement statement) throws SQLException public void log(PreparedStatement statement) throws SQLException
{ {
statement.setInt(1, this.timeStamp); statement.setInt(1, this.timeStamp);
statement.setString(2, this.type); statement.setString(2, this.version);
statement.setString(3, this.stackTrace); statement.setString(3, this.buildHash);
statement.setString(4, this.type);
statement.setString(5, this.stackTrace);
statement.addBatch(); statement.addBatch();
} }
} }