If the node simply closes the connection, log that, too.
[jSite.git] / src / main / java / de / todesbaum / util / freenet / fcp2 / Connection.java
index ff11cdf..eccc89b 100644 (file)
@@ -18,6 +18,9 @@
 
 package de.todesbaum.util.freenet.fcp2;
 
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Logger.getLogger;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -29,6 +32,7 @@ import java.net.Socket;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.logging.Logger;
 
 import net.pterodactylus.util.io.Closer;
 import net.pterodactylus.util.io.StreamCopier;
@@ -44,6 +48,8 @@ import de.todesbaum.util.io.TempFileInputStream;
  */
 public class Connection {
 
+       private static final Logger logger = getLogger(Connection.class.getName());
+
        /** The listeners that receive events from this connection. */
        private List<ConnectionListener> connectionListeners = new ArrayList<ConnectionListener>();
 
@@ -227,6 +233,7 @@ public class Connection {
                synchronized (this) {
                        notify();
                }
+               logger.log(FINE, "Connection terminated.", new Exception());
                fireConnectionTerminated();
        }
 
@@ -315,6 +322,7 @@ public class Connection {
                                        line = nodeReader.readLine();
                                        // System.err.println("> " + line);
                                        if (line == null) {
+                        logger.fine("Connection was closed.");
                                                break;
                                        }
                                        if (message == null) {
@@ -367,7 +375,7 @@ public class Connection {
                                        throw new IOException("Unexpected line: " + line);
                                }
                        } catch (IOException ioe1) {
-                               // ioe1.printStackTrace();
+                               logger.log(FINE, "Exception while reading from node.", ioe1);
                        } finally {
                                if (nodeReader != null) {
                                        try {