From 3ee493179c63f8a90e0c6204a2cdbc90775ec711 Mon Sep 17 00:00:00 2001 From: Robert Novotny Date: Sun, 18 Mar 2018 19:50:49 +0000 Subject: [PATCH] Cleanup in logging verbosity --- pom.xml | 7 +++++- .../com/github/novotnyr/aedile/Aedile.java | 22 +++++++++++++++++++ .../aedile/ConsulConfigurationRepository.java | 2 +- src/main/resources/logback.xml | 11 ++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/logback.xml diff --git a/pom.xml b/pom.xml index f5c365f..77126e5 100644 --- a/pom.xml +++ b/pom.xml @@ -68,10 +68,15 @@ commons-io 2.4 + + org.slf4j + slf4j-api + 1.7.25 + ch.qos.logback logback-classic - 1.0.13 + 1.2.3 runtime true diff --git a/src/main/java/com/github/novotnyr/aedile/Aedile.java b/src/main/java/com/github/novotnyr/aedile/Aedile.java index ae9b55c..bfcb688 100644 --- a/src/main/java/com/github/novotnyr/aedile/Aedile.java +++ b/src/main/java/com/github/novotnyr/aedile/Aedile.java @@ -11,10 +11,14 @@ import com.github.novotnyr.aedile.git.GitImporter; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; public class Aedile { + public static final Logger logger = LoggerFactory.getLogger(Aedile.class); + public static void main(String[] args) { CommandLineConfiguration commandLineConfiguration = new CommandLineConfiguration(); CmdLineParser cmdLineParser = new CmdLineParser(commandLineConfiguration); @@ -73,6 +77,7 @@ private static void filesystemImport(FilesystemImportCommand commandConfiguratio File configurationSubDirectory = new File(configurationSubDirectoryString); ConsulConfiguration consulConfiguration = ConsulConfiguration.fromEnvironment(); + describeToLog(consulConfiguration); ConsulConfigurationRepository repository = new ConsulConfigurationRepository(consulConfiguration); PropertyFilesDirectoryImporter directoryImporter = new PropertyFilesDirectoryImporter(repository); @@ -106,4 +111,21 @@ private static void gitImport(GitImportConfiguration gitImportConfiguration) { GitImporter importer = new GitImporter(); importer.run(configurationFile); } + + // Noncommand methods + private static void describeToLog(ConsulConfiguration c) { + if (! logger.isInfoEnabled()) { + return; + } + StringBuilder msg = new StringBuilder("Consul configured: "); + if (c.getUser() != null) { + msg.append(c.getUser()).append("@"); + } + msg.append(c.getHost()) + .append(":") + .append(c.getPort()); + + logger.info(msg.toString()); + } + } diff --git a/src/main/java/com/github/novotnyr/aedile/ConsulConfigurationRepository.java b/src/main/java/com/github/novotnyr/aedile/ConsulConfigurationRepository.java index dfb514e..e828a99 100644 --- a/src/main/java/com/github/novotnyr/aedile/ConsulConfigurationRepository.java +++ b/src/main/java/com/github/novotnyr/aedile/ConsulConfigurationRepository.java @@ -97,7 +97,7 @@ public void store(String prefix, String name, Map configuration) { } private void store(NamedMap map) { - logger.info("Creating Consul client {}:{}", this.configuration.getHost(), this.configuration.getPort()); + logger.debug("Creating Consul client {}:{}", this.configuration.getHost(), this.configuration.getPort()); store(getConsulClient(), map); } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..14043ce --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,11 @@ + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file