mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2025-01-29 22:51:35 +01:00
Add connection config to DebugReport
This commit is contained in:
parent
c9a811c758
commit
6eb4dcb80e
@ -21,6 +21,8 @@ package com.discordsrv.common.debug;
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.config.configurate.manager.MessagesConfigSingleManager;
|
||||
import com.discordsrv.common.config.configurate.manager.abstraction.ConfigurateConfigManager;
|
||||
import com.discordsrv.common.config.connection.ConnectionConfig;
|
||||
import com.discordsrv.common.config.connection.StorageConfig;
|
||||
import com.discordsrv.common.config.messages.MessagesConfig;
|
||||
import com.discordsrv.common.debug.file.DebugFile;
|
||||
import com.discordsrv.common.debug.file.KeyValueDebugFile;
|
||||
@ -33,6 +35,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.loader.AbstractConfigurationLoader;
|
||||
@ -75,6 +78,7 @@ public class DebugReport {
|
||||
addFile(config(78, manager));
|
||||
addFile(rawConfig(78, manager));
|
||||
}
|
||||
addFile(activeLimitedConnectionsConfig()); // 77
|
||||
}
|
||||
|
||||
public Paste upload(PasteService service) throws Throwable {
|
||||
@ -212,6 +216,32 @@ public class DebugReport {
|
||||
return readFile(order, manager.filePath());
|
||||
}
|
||||
|
||||
private DebugFile activeLimitedConnectionsConfig() {
|
||||
ConnectionConfig config = discordSRV.connectionConfig();
|
||||
StorageConfig.Pool poolConfig = config.storage.remote.poolOptions;
|
||||
|
||||
Map<String, Object> values = new LinkedHashMap<>();
|
||||
values.put("minecraft-auth.allow", config.minecraftAuth.allow);
|
||||
values.put("minecraft-auth.token_set", StringUtils.isNotBlank(config.minecraftAuth.token));
|
||||
|
||||
values.put("storage.backend", config.storage.backend);
|
||||
values.put("storage.sql-table-prefix", config.storage.sqlTablePrefix);
|
||||
values.put("storage.remote.pool-options.keepalive-time", poolConfig.keepaliveTime);
|
||||
values.put("storage.remote.pool-options.maxiumum-lifetime", poolConfig.maximumLifetime);
|
||||
values.put("storage.remote.pool-options.maximum-pool-size", poolConfig.maximumPoolSize);
|
||||
values.put("storage.remote.pool-options.minimum-pool-size", poolConfig.minimumPoolSize);
|
||||
|
||||
values.put("update.notification-enabled", config.update.notificationEnabled);
|
||||
values.put("update.notification-in-game", config.update.notificationInGame);
|
||||
values.put("update.first-party-notification", config.update.firstPartyNotification);
|
||||
values.put("update.github.enabled", config.update.github.enabled);
|
||||
values.put("update.github.api-token_set", StringUtils.isNotBlank(config.update.github.apiToken));
|
||||
values.put("update.security.enabled", config.update.security.enabled);
|
||||
values.put("update.security.force", config.update.security.force);
|
||||
|
||||
return new KeyValueDebugFile(77, "connections.json", values, true);
|
||||
}
|
||||
|
||||
private DebugFile readFile(int order, Path file) {
|
||||
String fileName = file.getFileName().toString();
|
||||
if (!Files.exists(file)) {
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
package com.discordsrv.common.debug.file;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class KeyValueDebugFile implements DebugFile {
|
||||
@ -31,11 +31,17 @@ public class KeyValueDebugFile implements DebugFile {
|
||||
private final int order;
|
||||
private final String name;
|
||||
private final Map<String, Object> values;
|
||||
private final boolean prettyPrint;
|
||||
|
||||
public KeyValueDebugFile(int order, String name, Map<String, Object> values) {
|
||||
this(order, name, values, false);
|
||||
}
|
||||
|
||||
public KeyValueDebugFile(int order, String name, Map<String, Object> values, boolean prettyPrint) {
|
||||
this.order = order;
|
||||
this.name = name;
|
||||
this.values = values;
|
||||
this.prettyPrint = prettyPrint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,8 +57,12 @@ public class KeyValueDebugFile implements DebugFile {
|
||||
@Override
|
||||
public String content() {
|
||||
try {
|
||||
return OBJECT_MAPPER.writeValueAsString(values);
|
||||
} catch (JsonProcessingException e) {
|
||||
if (prettyPrint) {
|
||||
return OBJECT_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(values);
|
||||
} else {
|
||||
return OBJECT_MAPPER.writeValueAsString(values);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return ExceptionUtils.getStackTrace(e);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user