Skip to content

Commit

Permalink
Cleanup in logging verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
novotnyr committed Mar 18, 2018
1 parent a11f9ef commit 3ee4931
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<version>1.2.3</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/github/novotnyr/aedile/Aedile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public <K, V> void store(String prefix, String name, Map<K, V> configuration) {
}

private <K, V> void store(NamedMap<K, V> 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);
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="console"/>
</root>
</configuration>

0 comments on commit 3ee4931

Please sign in to comment.