Improve logging
This commit is contained in:
@@ -64,8 +64,8 @@ public class DirectoryConfig {
|
||||
public void build() {
|
||||
log.info("--- Directory config ---");
|
||||
log.info("Exclude:");
|
||||
log.info("\tHomeserver: {}", getExclude().getHomeserver());
|
||||
log.info("\t3PID: {}", getExclude().getThreepid());
|
||||
log.info(" Homeserver: {}", getExclude().getHomeserver());
|
||||
log.info(" 3PID: {}", getExclude().getThreepid());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
package io.kamax.mxisd.config;
|
||||
|
||||
import io.kamax.matrix.json.GsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
@@ -32,21 +34,29 @@ import java.util.Optional;
|
||||
|
||||
public class YamlConfigLoader {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(YamlConfigLoader.class);
|
||||
|
||||
public static MxisdConfig loadFromFile(String path) throws IOException {
|
||||
log.debug("Reading config from {}", path);
|
||||
Representer rep = new Representer();
|
||||
rep.getPropertyUtils().setAllowReadOnlyProperties(true);
|
||||
rep.getPropertyUtils().setSkipMissingProperties(true);
|
||||
Yaml yaml = new Yaml(new Constructor(MxisdConfig.class), rep);
|
||||
try (FileInputStream is = new FileInputStream(path)) {
|
||||
Object o = yaml.load(is);
|
||||
return GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class);
|
||||
log.debug("Read config in memory from {}", path);
|
||||
MxisdConfig cfg = GsonUtil.get().fromJson(GsonUtil.get().toJson(o), MxisdConfig.class);
|
||||
log.info("Loaded config from {}", path);
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<MxisdConfig> tryLoadFromFile(String path) {
|
||||
log.debug("Attempting to read config from {}", path);
|
||||
try {
|
||||
return Optional.of(loadFromFile(path));
|
||||
} catch (FileNotFoundException e) {
|
||||
log.info("No config file at {}", path);
|
||||
return Optional.empty();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -421,9 +421,9 @@ public abstract class LdapConfig {
|
||||
log.info("Port: {}", connection.getPort());
|
||||
log.info("TLS: {}", connection.isTls());
|
||||
log.info("Bind DN: {}", connection.getBindDn());
|
||||
log.info("Base DNs: {}");
|
||||
log.info("Base DNs:");
|
||||
for (String baseDN : connection.getBaseDNs()) {
|
||||
log.info("\t- {}", baseDN);
|
||||
log.info(" - {}", baseDN);
|
||||
}
|
||||
|
||||
log.info("Attribute: {}", GsonUtil.get().toJson(attribute));
|
||||
|
||||
@@ -38,9 +38,9 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
||||
log.info("--- E-mail Generator templates config ---");
|
||||
log.info("Invite: {}", getName(getInvite()));
|
||||
log.info("Session:");
|
||||
log.info("\tValidation: {}", getSession().getValidation());
|
||||
log.info("\tUnbind:");
|
||||
log.info("\t\tFraudulent: {}", getSession().getUnbind().getFraudulent());
|
||||
log.info(" Validation: {}", getSession().getValidation());
|
||||
log.info(" Unbind:");
|
||||
log.info(" Fraudulent: {}", getSession().getUnbind().getFraudulent());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
|
||||
log.info("--- SMS Generator templates config ---");
|
||||
log.info("Invite: {}", getName(getInvite()));
|
||||
log.info("Session:");
|
||||
log.info("\tValidation: {}", getSession().getValidation());
|
||||
log.info("\tUnbind:");
|
||||
log.info("\t\tFraudulent: {}", getSession().getUnbind().getFraudulent());
|
||||
log.info(" Validation: {}", getSession().getValidation());
|
||||
log.info(" Unbind:");
|
||||
log.info(" Fraudulent: {}", getSession().getUnbind().getFraudulent());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class NotificationConfig {
|
||||
public void build() {
|
||||
log.info("--- Notification config ---");
|
||||
log.info("Handlers:");
|
||||
handler.forEach((k, v) -> log.info("\t{}: {}", k, v));
|
||||
handler.forEach((k, v) -> log.info(" {}: {}", k, v));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user