#502 Replaced usages of System.out with logger.
This commit is contained in:
@ -22,6 +22,9 @@
|
||||
*/
|
||||
package com.iluwatar.producer.consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -37,6 +40,8 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
*
|
||||
@ -72,7 +77,7 @@ public class App {
|
||||
executorService.awaitTermination(10, TimeUnit.SECONDS);
|
||||
executorService.shutdownNow();
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error waiting for ExecutorService shutdown");
|
||||
LOGGER.error("Error waiting for ExecutorService shutdown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,11 +22,16 @@
|
||||
*/
|
||||
package com.iluwatar.producer.consumer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Class responsible for consume the {@link Item} produced by {@link Producer}
|
||||
*/
|
||||
public class Consumer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Consumer.class);
|
||||
|
||||
private final ItemQueue queue;
|
||||
|
||||
private final String name;
|
||||
@ -42,8 +47,7 @@ public class Consumer {
|
||||
public void consume() throws InterruptedException {
|
||||
|
||||
Item item = queue.take();
|
||||
System.out.println(String.format("Consumer [%s] consume item [%s] produced by [%s]", name,
|
||||
item.getId(), item.getProducer()));
|
||||
LOGGER.info("Consumer [{}] consume item [{}] produced by [{}]", name, item.getId(), item.getProducer());
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user