From 58fb4a6394cb19ee04e65d0e921cdf0ae6fdb6e3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 26 Jan 2016 21:43:38 +0300 Subject: s2s: logging --- src/main/java/com/juick/xmpp/s2s/ConnectionIn.java | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src/main/java/com/juick/xmpp/s2s/ConnectionIn.java') diff --git a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java index f484c9db..fad97c16 100644 --- a/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java +++ b/src/main/java/com/juick/xmpp/s2s/ConnectionIn.java @@ -37,7 +37,7 @@ public class ConnectionIn extends Connection implements Runnable { @Override public void run() { - System.out.println("STREAM FROM ? " + streamID + " START"); + LOGGER.info("STREAM FROM ? " + streamID + " START"); try { parser.setInput(new InputStreamReader(socket.getInputStream())); writer = new OutputStreamWriter(socket.getOutputStream()); @@ -67,10 +67,7 @@ public class ConnectionIn extends Connection implements Runnable { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } - - if (XMPPComponent.LOGFILE != null) { - logParser(); - } + logParser(); packetsRemote++; @@ -78,7 +75,7 @@ public class ConnectionIn extends Connection implements Runnable { if (tag.equals("db:result")) { String dfrom = parser.getAttributeValue(null, "from"); String to = parser.getAttributeValue(null, "to"); - System.out.println("STREAM FROM " + dfrom + " TO " + to + " " + streamID + " ASKING FOR DIALBACK"); + LOGGER.info("STREAM FROM " + dfrom + " TO " + to + " " + streamID + " ASKING FOR DIALBACK"); if (dfrom.endsWith(XMPPComponent.HOSTNAME) && (dfrom.equals(XMPPComponent.HOSTNAME) || dfrom.endsWith("." + XMPPComponent.HOSTNAME))) { break; } @@ -109,10 +106,10 @@ public class ConnectionIn extends Connection implements Runnable { } if (valid) { sendStanza(""); - System.out.println("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY VALID"); + LOGGER.info("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY VALID"); } else { sendStanza(""); - System.err.println("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY INVALID"); + LOGGER.warning("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY INVALID"); } } else if (tag.equals("presence") && checkFromTo(parser)) { Presence p = Presence.parse(parser, null); @@ -123,7 +120,7 @@ public class ConnectionIn extends Connection implements Runnable { updateTsRemoteData(); Message msg = Message.parse(parser, XMPPComponent.childParsers); if (msg != null && (msg.type == null || !msg.type.equals(Message.Type.error))) { - System.out.println("STREAM " + streamID + ": " + msg.toString()); + LOGGER.info("STREAM " + streamID + ": " + msg.toString()); if (!JuickBot.incomingMessage(msg)) { XMPPComponent.connRouter.sendStanza(msg.toString()); } @@ -133,14 +130,14 @@ public class ConnectionIn extends Connection implements Runnable { String type = parser.getAttributeValue(null, "type"); String xml = XmlUtils.parseToString(parser, true); if (type == null || !type.equals(Iq.Type.error)) { - System.out.println("STREAM " + streamID + ": " + xml); + LOGGER.info("STREAM " + streamID + ": " + xml); XMPPComponent.connRouter.sendStanza(xml); } } else { - System.out.println("STREAM " + streamID + ": " + XmlUtils.parseToString(parser, true)); + LOGGER.info("STREAM " + streamID + ": " + XmlUtils.parseToString(parser, true)); } } - System.err.println("STREAM " + streamID + " FINISHED"); + LOGGER.warning("STREAM " + streamID + " FINISHED"); XMPPComponent.removeConnectionIn(this); closeConnection(); } catch (EOFException ex) { @@ -148,7 +145,7 @@ public class ConnectionIn extends Connection implements Runnable { XMPPComponent.removeConnectionIn(this); closeConnection(); } catch (Exception e) { - System.err.println("STREAM " + streamID + " ERROR:" + e.toString()); + LOGGER.warning("STREAM " + streamID + " ERROR:" + e.toString()); e.printStackTrace(); XMPPComponent.removeConnectionIn(this); closeConnection(); @@ -164,10 +161,10 @@ public class ConnectionIn extends Connection implements Runnable { sendStanza(""); if (type.equals("valid")) { from.add(sfrom); - System.out.println("STREAM FROM " + sfrom + " " + streamID + " READY"); + LOGGER.info("STREAM FROM " + sfrom + " " + streamID + " READY"); } } catch (IOException e) { - System.err.println("STREAM FROM " + sfrom + " " + streamID + " ERROR: " + e.toString()); + LOGGER.warning("STREAM FROM " + sfrom + " " + streamID + " ERROR: " + e.toString()); } } -- cgit v1.2.3