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/Connection.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/juick/xmpp/s2s/Connection.java') diff --git a/src/main/java/com/juick/xmpp/s2s/Connection.java b/src/main/java/com/juick/xmpp/s2s/Connection.java index 699e52bf..6d32abbe 100644 --- a/src/main/java/com/juick/xmpp/s2s/Connection.java +++ b/src/main/java/com/juick/xmpp/s2s/Connection.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.net.Socket; import java.util.Date; +import java.util.logging.Logger; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; import org.xmlpull.mxp1.MXParser; @@ -16,6 +17,8 @@ import org.xmlpull.v1.XmlPullParser; */ public class Connection { + protected static final Logger LOGGER = Logger.getLogger(Connection.class.getName()); + public String streamID; public long tsCreated = 0; public long tsLocalData = 0; @@ -29,15 +32,6 @@ public class Connection { tsCreated = System.currentTimeMillis(); } - public void logXml(String xml) { - try { - FileWriter logFile = new FileWriter(XMPPComponent.LOGFILE, true); - logFile.write(new Date().toString() + "\t" + streamID + "\t" + xml); - logFile.close(); - } catch (IOException e) { - } - } - public void logParser() { if (streamID == null) { return; @@ -47,12 +41,12 @@ public class Connection { tag += " " + parser.getAttributeName(i) + "=\"" + parser.getAttributeValue(i) + "\""; } tag += ">...\n"; - logXml(tag); + LOGGER.fine(tag); } public void sendStanza(String xml) throws IOException { - if (XMPPComponent.LOGFILE != null && streamID != null) { - logXml("OUT: " + xml + "\n"); + if (streamID != null) { + LOGGER.fine("OUT: " + xml + "\n"); } writer.write(xml); writer.flush(); @@ -62,8 +56,8 @@ public class Connection { } void closeConnection() { - if (XMPPComponent.LOGFILE != null && streamID != null) { - logXml("CLOSING STREAM\n"); + if (streamID != null) { + LOGGER.info(String.format("CLOSING STREAM %s", streamID)); } try { -- cgit v1.2.3