mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-28 06:20:07 +01:00
[Debug] Improved debug channel usage
This commit is contained in:
parent
bd636892d6
commit
6ca86b8c76
@ -99,14 +99,14 @@ public abstract class InfoSystem implements SubSystem {
|
|||||||
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
public void sendRequest(InfoRequest infoRequest) throws WebException {
|
||||||
try {
|
try {
|
||||||
if (!connectionSystem.isServerAvailable()) {
|
if (!connectionSystem.isServerAvailable()) {
|
||||||
logger.debug(DebugChannels.INFO_REQUESTS, "Main server unavailable, running locally.");
|
logger.getDebugLogger().logOn(DebugChannels.INFO_REQUESTS, "Main server unavailable, running locally.");
|
||||||
runLocally(infoRequest);
|
runLocally(infoRequest);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connectionSystem.sendInfoRequest(infoRequest);
|
connectionSystem.sendInfoRequest(infoRequest);
|
||||||
} catch (WebException original) {
|
} catch (WebException original) {
|
||||||
try {
|
try {
|
||||||
logger.debug(DebugChannels.INFO_REQUESTS, "Exception during request: " + original.toString() + ", running locally.");
|
logger.getDebugLogger().logOn(DebugChannels.INFO_REQUESTS, "Exception during request: " + original.toString() + ", running locally.");
|
||||||
runLocally(infoRequest);
|
runLocally(infoRequest);
|
||||||
} catch (NoServersException e2) {
|
} catch (NoServersException e2) {
|
||||||
throw original;
|
throw original;
|
||||||
|
@ -6,6 +6,7 @@ package com.djrapitops.plan.system.info;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
import com.djrapitops.plan.api.exceptions.connection.NoServersException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
|
import com.djrapitops.plan.system.DebugChannels;
|
||||||
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
import com.djrapitops.plan.system.info.connection.ConnectionSystem;
|
||||||
import com.djrapitops.plan.system.info.request.InfoRequest;
|
import com.djrapitops.plan.system.info.request.InfoRequest;
|
||||||
import com.djrapitops.plan.system.info.request.InfoRequestFactory;
|
import com.djrapitops.plan.system.info.request.InfoRequestFactory;
|
||||||
@ -48,7 +49,7 @@ public class ServerInfoSystem extends InfoSystem {
|
|||||||
if (infoRequest instanceof SetupRequest) {
|
if (infoRequest instanceof SetupRequest) {
|
||||||
throw new NoServersException("Set-up requests can not be run locally.");
|
throw new NoServersException("Set-up requests can not be run locally.");
|
||||||
}
|
}
|
||||||
logger.debug("LocalRun: " + infoRequest.getClass().getSimpleName());
|
logger.getDebugLogger().logOn(DebugChannels.INFO_REQUESTS, "Local: " + infoRequest.getClass().getSimpleName());
|
||||||
infoRequest.runLocally();
|
infoRequest.runLocally();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.djrapitops.plan.system.webserver;
|
package com.djrapitops.plan.system.webserver;
|
||||||
|
|
||||||
|
import com.djrapitops.plan.system.DebugChannels;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.locale.Locale;
|
import com.djrapitops.plan.system.locale.Locale;
|
||||||
import com.djrapitops.plan.system.settings.Settings;
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
@ -94,7 +95,10 @@ public class RequestHandler implements HttpHandler {
|
|||||||
} finally {
|
} finally {
|
||||||
exchange.close();
|
exchange.close();
|
||||||
if (inDevMode) {
|
if (inDevMode) {
|
||||||
logger.debug(requestString + " Response code: " + responseCode + timings.end(requestString).map(Benchmark::toString).orElse("-"));
|
logger.getDebugLogger().logOn(
|
||||||
|
DebugChannels.WEB_REQUESTS,
|
||||||
|
timings.end(requestString).map(Benchmark::toString).orElse("-") + " Code: " + responseCode
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,10 @@ public class DebugPage implements Page {
|
|||||||
|
|
||||||
TabsElement.Tab[] tabs = channels.entrySet().stream()
|
TabsElement.Tab[] tabs = channels.entrySet().stream()
|
||||||
.sorted((one, two) -> String.CASE_INSENSITIVE_ORDER.compare(one.getKey(), two.getKey()))
|
.sorted((one, two) -> String.CASE_INSENSITIVE_ORDER.compare(one.getKey(), two.getKey()))
|
||||||
.map(channel -> new TabsElement.Tab(channel.getKey(), debugChannelContent(channel.getKey(), channel.getValue())))
|
.map(channel -> {
|
||||||
|
String name = channel.getKey().isEmpty() ? "Default" : channel.getKey();
|
||||||
|
return new TabsElement.Tab(name, debugChannelContent(name, channel.getValue()));
|
||||||
|
})
|
||||||
.toArray(TabsElement.Tab[]::new);
|
.toArray(TabsElement.Tab[]::new);
|
||||||
|
|
||||||
content.append(new TabsElement(tabs).toHtmlFull());
|
content.append(new TabsElement(tabs).toHtmlFull());
|
||||||
|
Loading…
Reference in New Issue
Block a user