aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-10 04:50:07 +0700
committerGravatar Vitaly Takmazov2016-11-10 21:41:14 +0300
commit09221ab5695e99b2df1130ea923c39625ec85429 (patch)
tree58c775188d25239a1e32a83f8007e5f1679d49ee /juick-xmpp
parent705d4f87c97dfa20eb6daa88b93ff124fa401b92 (diff)
using slf4j + logback for logging
Diffstat (limited to 'juick-xmpp')
-rw-r--r--juick-xmpp/build.gradle8
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/Connection.java11
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionIn.java18
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java9
4 files changed, 24 insertions, 22 deletions
diff --git a/juick-xmpp/build.gradle b/juick-xmpp/build.gradle
index 4a3c6bca..ae918f18 100644
--- a/juick-xmpp/build.gradle
+++ b/juick-xmpp/build.gradle
@@ -7,12 +7,14 @@ repositories {
mavenCentral()
}
+def springFrameworkVersion = '4.3.4.RELEASE'
+def jacksonVersion = '2.8.4'
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':juick-core')
- compile 'org.slf4j:slf4j-jdk14:1.7.21'
- def springFrameworkVersion = '4.3.4.RELEASE'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
compile "org.springframework:spring-webmvc:${springFrameworkVersion}"
- def jacksonVersion = '2.8.4'
compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jacksonVersion}"
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/Connection.java b/juick-xmpp/src/main/java/com/juick/components/s2s/Connection.java
index 0c1f3d4d..700293df 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/Connection.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/Connection.java
@@ -1,6 +1,8 @@
package com.juick.components.s2s;
import com.juick.components.XMPPServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -17,7 +19,6 @@ import java.nio.charset.Charset;
import java.security.*;
import java.security.cert.CertificateException;
import java.util.UUID;
-import java.util.logging.Logger;
/**
*
@@ -25,7 +26,7 @@ import java.util.logging.Logger;
*/
public class Connection {
- protected static final Logger logger = Logger.getLogger(Connection.class.getName());
+ protected static final Logger logger = LoggerFactory.getLogger(Connection.class);
public String streamID;
public long tsCreated = 0;
@@ -68,7 +69,7 @@ public class Connection {
sc = SSLContext.getInstance("TLSv1.2");
sc.init(kmf.getKeyManagers(), trustAllCerts, new SecureRandom());
} catch (Exception e) {
- logger.warning("tls unavailable");
+ logger.warn("tls unavailable");
}
}
@@ -81,12 +82,12 @@ public class Connection {
tag += " " + parser.getAttributeName(i) + "=\"" + parser.getAttributeValue(i) + "\"";
}
tag += ">...</" + parser.getName() + ">\n";
- logger.fine(tag);
+ logger.trace(tag);
}
public void sendStanza(String xml) throws IOException {
if (streamID != null) {
- logger.fine("OUT: " + xml + "\n");
+ logger.trace("OUT: " + xml + "\n");
}
writer.write(xml);
writer.flush();
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionIn.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionIn.java
index 41336582..8cc61e26 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionIn.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionIn.java
@@ -6,6 +6,8 @@ import com.juick.xmpp.JID;
import com.juick.xmpp.Message;
import com.juick.xmpp.Presence;
import com.juick.xmpp.utils.XmlUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xmlpull.v1.XmlPullParser;
import javax.net.ssl.SSLException;
@@ -17,8 +19,6 @@ import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
@@ -26,7 +26,7 @@ import java.util.logging.Logger;
*/
public class ConnectionIn extends Connection implements Runnable {
- private static final Logger LOGGER = Logger.getLogger(ConnectionIn.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionIn.class);
final public List<String> from = new ArrayList<>();
public long tsRemoteData = 0;
@@ -109,7 +109,7 @@ public class ConnectionIn extends Connection implements Runnable {
LOGGER.info("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY VALID");
} else {
sendStanza("<db:verify from='" + vto + "' to='" + vfrom + "' id='" + vid + "' type='invalid'/>");
- LOGGER.warning("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY INVALID");
+ LOGGER.warn("STREAM FROM " + vfrom + " " + streamID + " DIALBACK VERIFY INVALID");
}
} else if (tag.equals("presence") && checkFromTo(parser)) {
Presence p = Presence.parse(parser, null);
@@ -145,7 +145,7 @@ public class ConnectionIn extends Connection implements Runnable {
LOGGER.info("STREAM " + streamID + " SECURED");
restartParser();
} catch (SSLException sex) {
- LOGGER.warning("STREAM " + streamID + " SSL ERROR");
+ LOGGER.warn("STREAM " + streamID + " SSL ERROR");
sendStanza("<failed xmlns\"" + NS_TLS + "\" />");
xmpp.removeConnectionIn(this);
closeConnection();
@@ -156,7 +156,7 @@ public class ConnectionIn extends Connection implements Runnable {
LOGGER.info("STREAM " + streamID + ": " + XmlUtils.parseToString(parser, true));
}
}
- LOGGER.warning("STREAM " + streamID + " FINISHED");
+ LOGGER.warn("STREAM " + streamID + " FINISHED");
xmpp.removeConnectionIn(this);
closeConnection();
} catch (EOFException | SocketException ex) {
@@ -164,9 +164,9 @@ public class ConnectionIn extends Connection implements Runnable {
xmpp.removeConnectionIn(this);
closeConnection();
} catch (HostUnknownException e) {
- LOGGER.warning(e.getMessage());
+ LOGGER.warn(e.getMessage());
} catch (Exception e) {
- LOGGER.log(Level.WARNING, "STREAM " + streamID + " ERROR", e);
+ LOGGER.warn("STREAM " + streamID + " ERROR", e);
xmpp.removeConnectionIn(this);
closeConnection();
}
@@ -198,7 +198,7 @@ public class ConnectionIn extends Connection implements Runnable {
LOGGER.info("STREAM FROM " + sfrom + " " + streamID + " READY");
}
} catch (IOException e) {
- LOGGER.warning("STREAM FROM " + sfrom + " " + streamID + " ERROR: " + e.toString());
+ LOGGER.warn("STREAM FROM " + sfrom + " " + streamID + " ERROR: " + e.toString());
}
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java
index cedb3745..c15a2a25 100644
--- a/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java
+++ b/juick-xmpp/src/main/java/com/juick/components/s2s/ConnectionOut.java
@@ -18,7 +18,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.UUID;
-import java.util.logging.Level;
/**
* @author ugnich
@@ -132,7 +131,7 @@ public class ConnectionOut extends Connection implements Runnable {
restartParser();
sendOpenStream();
} catch (SSLException sex) {
- logger.log(Level.SEVERE, String.format("s2s ssl error: %s %s", to, streamID), sex);
+ logger.error(String.format("s2s ssl error: %s %s", to, streamID), sex);
sendStanza("<failed xmlns\"" + NS_TLS + "\" />");
xmpp.removeConnectionOut(this);
closeConnection();
@@ -144,7 +143,7 @@ public class ConnectionOut extends Connection implements Runnable {
}
}
- logger.warning("STREAM TO " + to + " " + streamID + " FINISHED");
+ logger.warn("STREAM TO " + to + " " + streamID + " FINISHED");
xmpp.removeConnectionOut(ConnectionOut.this);
closeConnection();
} catch (EOFException | SocketException eofex) {
@@ -152,7 +151,7 @@ public class ConnectionOut extends Connection implements Runnable {
xmpp.removeConnectionOut(ConnectionOut.this);
closeConnection();
} catch (Exception e) {
- logger.log(Level.SEVERE, String.format("s2s out exception: %s %s", to, streamID), e);
+ logger.error(String.format("s2s out exception: %s %s", to, streamID), e);
xmpp.removeConnectionOut(ConnectionOut.this);
closeConnection();
}
@@ -162,7 +161,7 @@ public class ConnectionOut extends Connection implements Runnable {
try {
sendStanza("<db:verify from='" + xmpp.HOSTNAME + "' to='" + to + "' id='" + sid + "'>" + key + "</db:verify>");
} catch (IOException e) {
- logger.log(Level.WARNING, "STREAM TO " + to + " " + streamID + " ERROR", e);
+ logger.warn("STREAM TO " + to + " " + streamID + " ERROR", e);
}
}
}