diff options
author | Alexander Alexeev | 2016-11-10 04:50:07 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-10 21:41:14 +0300 |
commit | 09221ab5695e99b2df1130ea923c39625ec85429 (patch) | |
tree | 58c775188d25239a1e32a83f8007e5f1679d49ee /juick-crosspost | |
parent | 705d4f87c97dfa20eb6daa88b93ff124fa401b92 (diff) |
using slf4j + logback for logging
Diffstat (limited to 'juick-crosspost')
-rw-r--r-- | juick-crosspost/build.gradle | 8 | ||||
-rw-r--r-- | juick-crosspost/src/main/java/com/juick/components/Crosspost.java | 22 |
2 files changed, 16 insertions, 14 deletions
diff --git a/juick-crosspost/build.gradle b/juick-crosspost/build.gradle index 4a3c6bca..ae918f18 100644 --- a/juick-crosspost/build.gradle +++ b/juick-crosspost/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-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java index c0f11959..ad667534 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -26,6 +26,8 @@ import com.juick.xmpp.extensions.JuickMessage; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.tuple.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.DisposableBean; import org.springframework.core.env.Environment; import org.springframework.jdbc.core.JdbcTemplate; @@ -42,8 +44,6 @@ import java.net.URLEncoder; import java.security.Key; import java.util.UUID; import java.util.concurrent.ExecutorService; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @@ -51,7 +51,7 @@ import java.util.logging.Logger; */ public class Crosspost implements DisposableBean, Stream.StreamListener, Message.MessageListener { - private static Logger logger = Logger.getLogger(Crosspost.class.getName()); + private static Logger logger = LoggerFactory.getLogger(Crosspost.class); public final static String TWITTERURL = "https://api.twitter.com/1.1/statuses/update.json"; public final static String FBURL = "https://graph.facebook.com/me/feed"; @@ -75,7 +75,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message env.getProperty("xmpp_password", ""), NumberUtils.toInt(env.getProperty("xmpp_port", ""), 5347)); service.submit(() -> xmpp.startParsing()); } catch (Exception e) { - logger.log(Level.SEVERE, e.getMessage(), e); + logger.error("crosspost exception", e); } } @@ -92,7 +92,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message xmpp.addListener((Stream.StreamListener) this); xmpp.addListener((Message.MessageListener) this); } catch (IOException e) { - logger.log(Level.SEVERE, e.getMessage(), e); + logger.error(e.getMessage(), e); } } @@ -102,7 +102,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message } @Override - public void onStreamFail(Exception e) {logger.log(Level.SEVERE, "XMPP STREAM FAIL", e);} + public void onStreamFail(Exception e) {logger.error("XMPP STREAM FAIL", e);} @Override public void onMessage(com.juick.xmpp.Message msg) { JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS); @@ -149,7 +149,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message conn.disconnect(); } catch (Exception e) { - logger.log(Level.SEVERE, "fbPost: " + e.getMessage(), e); + logger.error("fbPost: " + e.getMessage(), e); } return ret; } @@ -186,7 +186,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message conn.disconnect(); } catch (Exception e) { - logger.log(Level.SEVERE, "vkPost: " + e.getMessage(), e); + logger.error("vkPost: " + e.getMessage(), e); } return ret; } @@ -241,7 +241,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message conn.disconnect(); } catch (Exception e) { - logger.log(Level.SEVERE, "twitterPost: " + e.getMessage(), e); + logger.error("twitterPost: " + e.getMessage(), e); } return ret; } @@ -267,7 +267,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message return Base64.encodeBase64String(rawHmac); } catch (Exception e) { - logger.log(Level.SEVERE, "twitterSignature: " + e.getMessage(), e); + logger.error("twitterSignature: " + e.getMessage(), e); } return null; } @@ -283,7 +283,7 @@ public class Crosspost implements DisposableBean, Stream.StreamListener, Message } while (line != null); return str.toString(); } catch (Exception e) { - logger.log(Level.SEVERE, "streamToString: " + e.getMessage(), e); + logger.error("streamToString: " + e.getMessage(), e); } return null; } |