From 74da24c29fa7403eed48acb97bc2ffa72f22bc8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 8 Apr 2013 07:11:14 +0200 Subject: [PATCH] Use logger instead of System.out. --- src/main/java/net/pterodactylus/irc/Connection.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 6f0bd12..69aa648 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -33,6 +33,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.SynchronousQueue; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.net.SocketFactory; import net.pterodactylus.irc.event.ChannelJoined; @@ -66,6 +68,9 @@ import com.google.common.util.concurrent.Service; */ public class Connection extends AbstractExecutionThreadService implements Service { + /* The logger. */ + private static final Logger logger = Logger.getLogger(Connection.class.getName()); + /** The event bus. */ private final EventBus eventBus; @@ -282,7 +287,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic while (connected) { Reply reply = connectionHandler.readReply(); - System.err.println("<< " + reply); + logger.finest(String.format("<< %s", reply)); String command = reply.command(); List parameters = reply.parameters(); @@ -317,11 +322,13 @@ public class Connection extends AbstractExecutionThreadService implements Servic char modeSymbol = parameter.charAt(closeParen + modeCharacterIndex); nickPrefixes.put(String.valueOf(modeSymbol), String.valueOf(modeCharacter)); } + logger.fine(String.format("Parsed Prefixes: %s", nickPrefixes)); } } else if (parameter.startsWith("CHANTYPES=")) { for (int typeIndex = 10; typeIndex < parameter.length(); ++typeIndex) { channelTypes.add(parameter.charAt(typeIndex)); } + logger.fine(String.format("Parsed Channel Types: %s", channelTypes)); } } @@ -365,7 +372,6 @@ public class Connection extends AbstractExecutionThreadService implements Servic } } else if (command.equals("366")) { eventBus.post(new ChannelNicknames(this, parameters.get(1), nicks)); - System.out.println("Found Nicknames: " + nicks); nicks.clear(); /* common channel join errors. */ @@ -392,9 +398,9 @@ public class Connection extends AbstractExecutionThreadService implements Servic oldConnectionStatus = connectionStatus; } } catch (IOException ioe1) { - ioe1.printStackTrace(); + logger.log(Level.WARNING, "I/O error", ioe1); } finally { - System.out.println("Closing Connection."); + logger.info("Closing Connection."); try { Closeables.close(connectionHandler, true); } catch (IOException ioe1) { @@ -508,7 +514,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic commandBuilder.append(parameter); } - System.out.println(">> " + commandBuilder.toString()); + logger.finest(String.format(">> %s", commandBuilder)); outputStream.write((commandBuilder.toString() + "\r\n").getBytes("UTF-8")); outputStream.flush(); } -- 2.7.4