mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-07-04 14:25:32 +02:00
67 lines
1.7 KiB
Java
67 lines
1.7 KiB
Java
package com.eu.habbo.core;
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
import java.io.StringWriter;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
|
|
public class ErrorLog implements Loggable
|
|
{
|
|
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 String type;
|
|
public final String stackTrace;
|
|
|
|
public ErrorLog(String type, Throwable e)
|
|
{
|
|
|
|
this.version = Emulator.version;
|
|
this.buildHash = Emulator.version;
|
|
|
|
this.timeStamp = Emulator.getIntUnixTimestamp();
|
|
this.type = type;
|
|
|
|
StringWriter sw = new StringWriter();
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
e.printStackTrace(pw);
|
|
this.stackTrace = sw.toString();
|
|
|
|
try
|
|
{
|
|
pw.close();
|
|
sw.close();
|
|
} catch (IOException e1)
|
|
{
|
|
Emulator.getLogging().logErrorLine(e1);
|
|
}
|
|
}
|
|
|
|
public ErrorLog(String type, String message)
|
|
{
|
|
this.version = Emulator.version;
|
|
this.buildHash = Emulator.build;
|
|
|
|
this.timeStamp = Emulator.getIntUnixTimestamp();
|
|
this.type = type;
|
|
this.stackTrace = message;
|
|
}
|
|
|
|
@Override
|
|
public void log(PreparedStatement statement) throws SQLException
|
|
{
|
|
statement.setInt(1, this.timeStamp);
|
|
statement.setString(2, this.version);
|
|
statement.setString(3, this.buildHash);
|
|
statement.setString(4, this.type);
|
|
statement.setString(5, this.stackTrace);
|
|
statement.addBatch();
|
|
}
|
|
}
|