From 4f8cd2e68db8026dd0cd1fb2b6827d19d15e5f1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 6 Jun 2013 06:38:11 +0200 Subject: [PATCH] Add logging. --- .../java/net/pterodactylus/sonitus/data/filter/PipelineFilter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/PipelineFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/PipelineFilter.java index e4c2d81..9bc86e9 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/PipelineFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/PipelineFilter.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.logging.Logger; import net.pterodactylus.sonitus.data.AbstractFilter; import net.pterodactylus.sonitus.data.DataPacket; @@ -39,6 +40,9 @@ import com.google.common.collect.Maps; */ public class PipelineFilter extends AbstractFilter implements Filter { + /** The logger. */ + private static final Logger logger = Logger.getLogger(PipelineFilter.class.getName()); + /** The first filter. */ private final Filter source; @@ -89,6 +93,7 @@ public class PipelineFilter extends AbstractFilter implements Filter { Connection connection = new Connection(currentSource, Arrays.asList(filter)); filterConnections.put(filter, connection); String threadName = String.format("%s → %s", connection.source().name(), filter.name()); + logger.info(String.format("Starting Thread: %s.", threadName)); new Thread(connection, threadName).start(); currentSource = filter; } @@ -98,8 +103,10 @@ public class PipelineFilter extends AbstractFilter implements Filter { @Override public DataPacket get(int bufferSize) throws IOException { if (filterConnections.get(lastFilter).ioException().isPresent()) { + logger.info(String.format("Rethrowing exception from %s: %s", lastFilter.name(), filterConnections.get(lastFilter).ioException().get().getMessage())); throw filterConnections.get(lastFilter).ioException().get(); } + logger.info(String.format("Requesting %d bytes from %s...", bufferSize, lastFilter.name())); return lastFilter.get(bufferSize); } -- 2.7.4