#502 Replaced usages of System.out with logger.

This commit is contained in:
daniel-bryla
2016-10-23 19:59:03 +02:00
parent 4ca205c03c
commit 0438811489
154 changed files with 1155 additions and 792 deletions

View File

@ -21,6 +21,9 @@
* THE SOFTWARE.
*/
package com.iluwatar.promise;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
@ -60,6 +63,8 @@ import java.util.concurrent.Executors;
*/
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
private static final String DEFAULT_URL = "https://raw.githubusercontent.com/iluwatar/java-design-patterns/Promise/promise/README.md";
private final ExecutorService executor;
private final CountDownLatch stopLatch;
@ -98,7 +103,7 @@ public class App {
lowestFrequencyChar()
.thenAccept(
charFrequency -> {
System.out.println("Char with lowest frequency is: " + charFrequency);
LOGGER.info("Char with lowest frequency is: {}", charFrequency);
taskCompleted();
}
);
@ -112,7 +117,7 @@ public class App {
countLines()
.thenAccept(
count -> {
System.out.println("Line count is: " + count);
LOGGER.info("Line count is: {}", count);
taskCompleted();
}
);

View File

@ -22,6 +22,9 @@
*/
package com.iluwatar.promise;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@ -38,6 +41,8 @@ import java.util.Map.Entry;
public class Utility {
private static final Logger LOGGER = LoggerFactory.getLogger(Utility.class);
/**
* Calculates character frequency of the file provided.
* @param fileLocation location of the file.
@ -104,7 +109,7 @@ public class Utility {
* @return the absolute path of the file downloaded.
*/
public static String downloadFile(String urlString) throws MalformedURLException, IOException {
System.out.println("Downloading contents from url: " + urlString);
LOGGER.info("Downloading contents from url: {}", urlString);
URL url = new URL(urlString);
File file = File.createTempFile("promise_pattern", null);
try (Reader reader = new InputStreamReader(url.openStream());
@ -114,7 +119,7 @@ public class Utility {
writer.write(line);
writer.write("\n");
}
System.out.println("File downloaded at: " + file.getAbsolutePath());
LOGGER.info("File downloaded at: {}", file.getAbsolutePath());
return file.getAbsolutePath();
} catch (IOException ex) {
throw ex;