From d6fb4288688294d2f76325f14410db3091fea0fa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 11 Jul 2016 12:25:03 +0300 Subject: logging --- .../main/java/com/juick/xmpp/s2s/Connection.java | 8 +++---- .../java/com/juick/xmpp/s2s/ConnectionOut.java | 26 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'juick-www/src/main/java/com/juick/xmpp/s2s') diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java b/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java index eae6efaa..b7837b06 100644 --- a/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java +++ b/juick-www/src/main/java/com/juick/xmpp/s2s/Connection.java @@ -23,7 +23,7 @@ import java.util.logging.Logger; */ public class Connection { - protected static final Logger LOGGER = Logger.getLogger(Connection.class.getName()); + protected static final Logger logger = Logger.getLogger(Connection.class.getName()); public String streamID; public long tsCreated = 0; @@ -80,12 +80,12 @@ public class Connection { tag += " " + parser.getAttributeName(i) + "=\"" + parser.getAttributeValue(i) + "\""; } tag += ">...\n"; - LOGGER.fine(tag); + logger.fine(tag); } public void sendStanza(String xml) throws IOException { if (streamID != null) { - LOGGER.fine("OUT: " + xml + "\n"); + logger.fine("OUT: " + xml + "\n"); } writer.write(xml); writer.flush(); @@ -96,7 +96,7 @@ public class Connection { void closeConnection() { if (streamID != null) { - LOGGER.info(String.format("CLOSING STREAM %s", streamID)); + logger.info(String.format("CLOSING STREAM %s", streamID)); } try { diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java b/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java index 2552bfcd..24ed3363 100644 --- a/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java +++ b/juick-www/src/main/java/com/juick/xmpp/s2s/ConnectionOut.java @@ -58,7 +58,7 @@ public class ConnectionOut extends Connection implements Runnable { @Override public void run() { - LOGGER.info("STREAM TO " + to + " START"); + logger.info("STREAM TO " + to + " START"); try { socket = new Socket(); socket.connect(DNSQueries.getServerAddress(to)); @@ -72,7 +72,7 @@ public class ConnectionOut extends Connection implements Runnable { throw new Exception("STREAM TO " + to + " INVALID FIRST PACKET"); } - LOGGER.info("STREAM TO " + to + " " + streamID + " OPEN"); + logger.info("STREAM TO " + to + " " + streamID + " OPEN"); xmpp.addConnectionOut(ConnectionOut.this); boolean xmppversionnew = parser.getAttributeValue(null, "version") != null; if (!xmppversionnew) { @@ -90,16 +90,16 @@ public class ConnectionOut extends Connection implements Runnable { String type = parser.getAttributeValue(null, "type"); if (type != null && type.equals("valid")) { streamReady = true; - LOGGER.info("STREAM TO " + to + " " + streamID + " READY"); + logger.info("STREAM TO " + to + " " + streamID + " READY"); String cache = xmpp.getFromCache(to); if (cache != null) { - LOGGER.info("STREAM TO " + to + " " + streamID + " SENDING CACHE"); + logger.info("STREAM TO " + to + " " + streamID + " SENDING CACHE"); sendStanza(cache); } } else { - LOGGER.info("STREAM TO " + to + " " + streamID + " DIALBACK FAIL"); + logger.info("STREAM TO " + to + " " + streamID + " DIALBACK FAIL"); } XmlUtils.skip(parser); } else if (tag.equals("verify") && parser.getNamespace().equals(NS_DB)) { @@ -116,7 +116,7 @@ public class ConnectionOut extends Connection implements Runnable { } else if (tag.equals("features") && parser.getNamespace().equals(NS_STREAM)) { StreamFeatures features = StreamFeatures.parse(parser); if (!isSecured() && features.STARTTLS >= 0 && !xmpp.brokenSSLhosts.contains(to)) { - System.out.println("STREAM TO " + to + " " + streamID + " SECURING"); + logger.info("STREAM TO " + to + " " + streamID + " SECURING"); sendStanza(""); } else { processDialback(); @@ -127,11 +127,11 @@ public class ConnectionOut extends Connection implements Runnable { socket.getPort(), true); ((SSLSocket) socket).startHandshake(); setSecured(true); - System.out.println("STREAM " + streamID + " SECURED"); + logger.info("STREAM " + streamID + " SECURED"); restartParser(); sendOpenStream(); } catch (SSLException sex) { - LOGGER.log(Level.SEVERE, String.format("s2s ssl error: %s %s", to, streamID), sex); + logger.log(Level.SEVERE, String.format("s2s ssl error: %s %s", to, streamID), sex); sendStanza(""); xmpp.removeConnectionOut(this); closeConnection(); @@ -139,19 +139,19 @@ public class ConnectionOut extends Connection implements Runnable { } else if (isSecured() && tag.equals("stream") && parser.getNamespace().equals(NS_STREAM)) { streamID = parser.getAttributeValue(null, "id"); } else { - LOGGER.info("STREAM TO " + to + " " + streamID + ": " + XmlUtils.parseToString(parser, true)); + logger.info("STREAM TO " + to + " " + streamID + ": " + XmlUtils.parseToString(parser, true)); } } - LOGGER.warning("STREAM TO " + to + " " + streamID + " FINISHED"); + logger.warning("STREAM TO " + to + " " + streamID + " FINISHED"); xmpp.removeConnectionOut(ConnectionOut.this); closeConnection(); } catch (EOFException | SocketException eofex) { - LOGGER.info(String.format("STREAM %s %s CLOSED (dirty)", to, streamID)); + logger.info(String.format("STREAM %s %s CLOSED (dirty)", to, streamID)); xmpp.removeConnectionOut(ConnectionOut.this); closeConnection(); } catch (Exception e) { - LOGGER.log(Level.SEVERE, String.format("s2s out exception: %s %s", to, streamID), e); + logger.log(Level.SEVERE, String.format("s2s out exception: %s %s", to, streamID), e); xmpp.removeConnectionOut(ConnectionOut.this); closeConnection(); } @@ -161,7 +161,7 @@ public class ConnectionOut extends Connection implements Runnable { try { sendStanza("" + key + ""); } catch (IOException e) { - LOGGER.log(Level.WARNING, "STREAM TO " + to + " " + streamID + " ERROR", e); + logger.log(Level.WARNING, "STREAM TO " + to + " " + streamID + " ERROR", e); } } } -- cgit v1.2.3