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;
*/
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;
while (connected) {
Reply reply = connectionHandler.readReply();
- System.err.println("<< " + reply);
+ logger.finest(String.format("<< %s", reply));
String command = reply.command();
List<String> parameters = reply.parameters();
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));
}
}
}
} 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. */
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) {
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();
}