Made debug logs easier to read for Benchmarks & ConnectionLog

This commit is contained in:
Rsl1122 2018-02-07 11:40:23 +02:00
parent af3bdc642d
commit 7d64a4bfbb
5 changed files with 20 additions and 25 deletions

View File

@ -27,27 +27,27 @@ public abstract class ExecStatement {
}
public boolean execute(PreparedStatement statement) throws SQLException {
Benchmark.start(sql);
Benchmark.start("SQL: " + sql);
try {
prepare(statement);
return statement.executeUpdate() > 0;
} finally {
statement.close();
if (devMode) {
Log.debug(Benchmark.stopAndFormat(sql));
Log.debug(Benchmark.stopAndFormat("SQL: " + sql));
}
}
}
public void executeBatch(PreparedStatement statement) throws SQLException {
Benchmark.start(sql + " (Batch)");
Benchmark.start("SQL: " + sql + " (Batch)");
try {
prepare(statement);
statement.executeBatch();
} finally {
statement.close();
if (devMode) {
Log.debug(Benchmark.stopAndFormat(sql + " (Batch)"));
Log.debug(Benchmark.stopAndFormat("SQL: " + sql + " (Batch)"));
}
}
}

View File

@ -34,7 +34,7 @@ public abstract class QueryStatement<T> {
}
public T executeQuery(PreparedStatement statement) throws SQLException {
Benchmark.start(sql);
Benchmark.start("SQL: " + sql);
try {
statement.setFetchSize(fetchSize);
prepare(statement);
@ -44,7 +44,7 @@ public abstract class QueryStatement<T> {
} finally {
statement.close();
if (devMode) {
Log.debug(Benchmark.stopAndFormat(sql));
Log.debug(Benchmark.stopAndFormat("SQL: " + sql));
}
}
}

View File

@ -27,18 +27,18 @@ public class ConnectionLog {
/**
* Get a map sorted by Addresses, then Requests and then Log entries.
*
* @return {@code Map<"-> "/"<- "+Address, Map<InfoRequestClassname, ConnectionLog.Entry>>}
* @return {@code Map<"In: "/"Out: "+Address, Map<InfoRequestClassname, ConnectionLog.Entry>>}
*/
public static Map<String, Map<String, Entry>> getLogEntries() {
return getInstance().getLog();
}
public static void logConnectionTo(Server server, InfoRequest request, int responseCode) {
logConnection(server.getWebAddress(), "-> " + request.getClass().getSimpleName(), responseCode);
logConnection(server.getWebAddress(), "Out: " + request.getClass().getSimpleName(), responseCode);
}
public static void logConnectionFrom(String server, String requestTarget, int responseCode) {
logConnection(server, "<- " + requestTarget, responseCode);
logConnection(server, "In: " + requestTarget, responseCode);
}
private static void logConnection(String address, String infoRequestName, int responseCode) {

View File

@ -56,8 +56,8 @@ public class DebugPageResponse extends ErrorResponse {
appendConnectionLog(content);
appendLoggedErrors(content);
appendDebugLog(content);
appendBenchmarks(content);
appendDebugLog(content);
appendConfig(content);
return content.toString();

View File

@ -65,7 +65,7 @@ public class Analysis {
private AnalysisData runAnalysis() throws Exception {
((BukkitTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
Benchmark.start("Analysis");
Benchmark.start("Analysis: Total");
log(Locale.get(Msg.ANALYSIS_START).toString());
return analyze();
}
@ -115,7 +115,7 @@ public class Analysis {
}
Map<PluginData, AnalysisContainer> containers = new HashMap<>();
Benchmark.start("Analysis", "3rd party Analysis");
Benchmark.start("Analysis", "Analysis: 3rd party");
List<PluginData> sources = HookHandler.getInstance().getAdditionalDataSources();
Log.logDebug("Analysis", "Additional Sources: " + sources.size());
@ -123,7 +123,7 @@ public class Analysis {
PlanPlugin plugin = PlanPlugin.getInstance();
StaticHolder.saveInstance(this.getClass(), plugin.getClass());
try {
Benchmark.start("Analysis", "Source " + source.getSourcePlugin());
Benchmark.start("Analysis", "Analysis: Source " + source.getSourcePlugin());
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
if (container != null && !container.isEmpty()) {
@ -134,10 +134,10 @@ public class Analysis {
Log.error("A PluginData-source caused an exception: " + source.getSourcePlugin());
Log.toLog(this.getClass().getName(), e);
} finally {
Benchmark.stop("Analysis", "Source " + source.getSourcePlugin());
Benchmark.stop("Analysis", "Analysis: Source " + source.getSourcePlugin());
}
});
Benchmark.stop("Analysis", "3rd party Analysis");
Benchmark.stop("Analysis", "Analysis: 3rd party");
return containers;
}
@ -151,16 +151,11 @@ public class Analysis {
private AnalysisData analyze() throws Exception {
log(Locale.get(Msg.ANALYSIS_FETCH).toString());
Benchmark.start("Fetch Phase");
Log.logDebug("Database", "Analysis Fetch");
Log.logDebug("Analysis", "Analysis Fetch Phase");
Benchmark.start("Analysis", "Analysis: Fetch Phase");
try {
Benchmark.start("Create Empty dataset");
AnalysisData analysisData = new AnalysisData();
Benchmark.stop("Analysis", "Create Empty dataset");
Benchmark.start("Fetch Phase");
ServerProfile server = database.fetch().getServerProfile(serverUUID);
if (analysingThisServer) {
server.addActiveSessions(new HashMap<>(SessionCache.getActiveSessions()));
@ -169,17 +164,17 @@ public class Analysis {
updatePlayerNameCache(server);
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
long fetchPhaseLength = Benchmark.stop("Analysis", "Analysis: Fetch Phase");
setBannedByPlugins(server);
Benchmark.start("Analysis Phase");
Benchmark.start("Analysis", "Analysis: Data Analysis");
Log.logDebug("Analysis", "Analysis Phase");
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(server.getPlayerCount(), fetchPhaseLength));
analysisData.analyze(server);
Benchmark.stop("Analysis", "Analysis Phase");
Benchmark.stop("Analysis", "Analysis: Data Analysis");
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)");
@ -187,7 +182,7 @@ public class Analysis {
return analysisData;
} finally {
Analysis.updateRefreshDate();
long time = Benchmark.stop("Analysis", "Analysis");
long time = Benchmark.stop("Analysis", "Analysis: Total");
Log.logDebug("Analysis");
Log.info(Locale.get(Msg.ANALYSIS_FINISHED).parse(time, ""));
Analysis.setServerProfile(null);