aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-rw-r--r--juick-api/build.gradle3
-rw-r--r--juick-api/src/main/java/com/juick/api/Main.java2
-rw-r--r--juick-api/src/main/java/com/juick/api/Messages.java9
-rw-r--r--juick-api/src/main/java/com/juick/api/SkypeEndpoint.java5
-rw-r--r--juick-api/src/main/java/com/juick/api/TelegramBotHook.java14
-rw-r--r--juick-core/build.gradle13
-rw-r--r--juick-core/src/main/java/com/juick/json/MessageSerializer.java8
-rw-r--r--juick-core/src/main/resources/logback.xml13
-rw-r--r--juick-crosspost/build.gradle8
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/Crosspost.java22
-rw-r--r--juick-demo/build.gradle3
-rw-r--r--juick-demo/src/main/java/com/juick/demo/Demo.java5
-rw-r--r--juick-notifications/build.gradle8
-rw-r--r--juick-notifications/src/main/java/com/juick/components/Notifications.java18
-rw-r--r--juick-rss/build.gradle3
-rw-r--r--juick-ws/build.gradle8
-rw-r--r--juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java11
-rw-r--r--juick-ws/src/main/java/com/juick/ws/XMPPConnection.java21
-rw-r--r--juick-www/build.gradle7
-rw-r--r--juick-www/src/main/java/com/juick/www/FacebookLogin.java12
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java20
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java8
-rw-r--r--juick-www/src/main/java/com/juick/www/PageTemplates.java9
-rw-r--r--juick-www/src/main/java/com/juick/www/Settings.java8
-rw-r--r--juick-www/src/main/java/com/juick/www/Utils.java9
-rw-r--r--juick-www/src/main/java/com/juick/www/VKontakteLogin.java16
-rw-r--r--juick-www/src/main/java/ru/sape/SapeConnection.java12
-rw-r--r--juick-www/src/main/webapp/WEB-INF/logging.properties.example5
-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
33 files changed, 187 insertions, 141 deletions
diff --git a/build.gradle b/build.gradle
index 8815a5a2..29598f34 100644
--- a/build.gradle
+++ b/build.gradle
@@ -21,7 +21,7 @@ dependencies {
testCompile 'com.fasterxml.jackson.core:jackson-databind:2.8.1'
testCompile 'org.springframework:spring-jdbc:4.3.4.RELEASE'
testCompile 'ch.vorburger.mariaDB4j:mariaDB4j:2.1.3'
- testCompile 'org.slf4j:slf4j-jdk14:1.7.21'
+ testCompile 'org.slf4j:slf4j-api:1.7.21'
testCompile 'junit:junit:4.12'
testRuntime 'mysql:mysql-connector-java:5.1.39'
}
diff --git a/juick-api/build.gradle b/juick-api/build.gradle
index 7801bda9..8bb9d227 100644
--- a/juick-api/build.gradle
+++ b/juick-api/build.gradle
@@ -17,6 +17,8 @@ repositories {
mavenCentral()
}
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
@@ -29,6 +31,7 @@ dependencies {
compile 'com.neovisionaries:nv-websocket-client:1.30'
compile 'org.apache.commons:commons-dbcp2:2.1.1'
compile 'net.coobird:thumbnailator:0.4.8'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
providedRuntime 'mysql:mysql-connector-java:5.1.39'
}
compileJava.options.encoding = 'UTF-8'
diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java
index 3c5c3303..80cbecd4 100644
--- a/juick-api/src/main/java/com/juick/api/Main.java
+++ b/juick-api/src/main/java/com/juick/api/Main.java
@@ -54,7 +54,6 @@ import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.logging.LogManager;
/**
*
@@ -81,7 +80,6 @@ public class Main extends HttpServlet implements Stream.StreamListener {
public void init() throws ServletException {
super.init();
try {
- LogManager.getLogManager().readConfiguration(getServletContext().getResourceAsStream("/WEB-INF/logging.properties"));
Properties conf = new Properties();
conf.load(getServletContext().getResourceAsStream("/WEB-INF/juick.conf"));
BasicDataSource dataSource = new BasicDataSource();
diff --git a/juick-api/src/main/java/com/juick/api/Messages.java b/juick-api/src/main/java/com/juick/api/Messages.java
index b1c875d2..d02d0ffe 100644
--- a/juick-api/src/main/java/com/juick/api/Messages.java
+++ b/juick-api/src/main/java/com/juick/api/Messages.java
@@ -12,6 +12,8 @@ import com.juick.xmpp.Message;
import com.juick.xmpp.Stream;
import com.juick.xmpp.extensions.JuickMessage;
import org.apache.commons.lang3.math.NumberUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
@@ -22,9 +24,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
/**
*
@@ -32,7 +31,7 @@ import java.util.stream.Collectors;
*/
public class Messages {
- private static final Logger logger = Logger.getLogger(Messages.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Messages.class);
JdbcTemplate sql;
@@ -184,7 +183,7 @@ public class Messages {
throw new Exception("Message not found");
}
} catch (Exception e) {
- logger.log(Level.SEVERE, "SETPOPULAR ERROR", e);
+ logger.error("SETPOPULAR ERROR", e);
}
}
diff --git a/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java b/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java
index cf141db2..74777305 100644
--- a/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java
+++ b/juick-api/src/main/java/com/juick/api/SkypeEndpoint.java
@@ -3,16 +3,17 @@ package com.juick.api;
import org.msbotframework4j.builder.bot.AbstractBot;
import org.msbotframework4j.core.model.Message;
import org.msbotframework4j.logging.BotLogger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
-import java.util.logging.Logger;
/**
* Created by vitalyster on 18.07.2016.
*/
public class SkypeEndpoint extends AbstractBot {
- private static final Logger logger = Logger.getLogger(SkypeEndpoint.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(SkypeEndpoint.class);
@Override
protected Message onMessage(Message request, BotLogger logger) {
return null;
diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
index 038166cc..72981705 100644
--- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
+++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java
@@ -16,6 +16,8 @@ import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup;
import com.pengrad.telegrambot.request.SendMessage;
import com.pengrad.telegrambot.response.SendResponse;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -26,8 +28,6 @@ import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import static com.juick.formatters.PlainTextFormatter.formatPost;
import static com.juick.formatters.PlainTextFormatter.formatUrl;
@@ -36,7 +36,7 @@ import static com.juick.formatters.PlainTextFormatter.formatUrl;
* Created by vt on 12/05/16.
*/
public class TelegramBotHook {
- private static final Logger logger = Logger.getLogger(TelegramBotHook.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(TelegramBotHook.class);
TelegramBot bot;
WebSocket ws;
@@ -90,7 +90,7 @@ public class TelegramBotHook {
});
ws.connect();
} catch (Exception e) {
- logger.log(Level.WARNING, "couldn't initialize telegram bot", e);
+ logger.warn("couldn't initialize telegram bot", e);
}
}
@@ -112,7 +112,7 @@ public class TelegramBotHook {
@Override
public void onFailure(SendMessage request, IOException e) {
- logger.log(Level.WARNING, "telegram failure", e);
+ logger.warn("telegram failure", e);
}
});
}
@@ -132,7 +132,7 @@ public class TelegramBotHook {
if (update.message() == null) {
message = update.editedMessage();
if (message == null) {
- logger.log(Level.SEVERE, "error parsing telegram update: " + update.toString());
+ logger.error("error parsing telegram update: " + update.toString());
return;
}
}
@@ -187,7 +187,7 @@ public class TelegramBotHook {
@Override
public void onFailure(SendMessage request, IOException e) {
- logger.log(Level.WARNING, "telegram failure", e);
+ logger.warn("telegram failure", e);
}
});
}
diff --git a/juick-core/build.gradle b/juick-core/build.gradle
index 0008642e..30802dad 100644
--- a/juick-core/build.gradle
+++ b/juick-core/build.gradle
@@ -5,13 +5,24 @@ repositories {
mavenCentral()
}
+def jacksonVersion = '2.8.4'
+def logbackVersion = '1.1.7'
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':deps:com.juick.xmpp')
- 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.core:jackson-annotations:${jacksonVersion}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jacksonVersion}"
+ compile "ch.qos.logback:logback-classic:${logbackVersion}"
+ compile "ch.qos.logback:logback-core:${logbackVersion}"
+ compile "ch.qos.logback:logback-access:${logbackVersion}"
+ compile "org.slf4j:slf4j-api:${slf4jVersion}"
+ compile "org.slf4j:jcl-over-slf4j:${slf4jVersion}"
+ compile "org.slf4j:log4j-over-slf4j:${slf4jVersion}"
+ compile "org.slf4j:jul-to-slf4j:${slf4jVersion}"
compile 'org.apache.httpcomponents:httpclient:4.5.2'
compile 'org.apache.commons:commons-lang3:3.5'
compile "org.springframework:spring-jdbc:4.3.4.RELEASE"
diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
index 9da828c9..3ef903f0 100644
--- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java
+++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java
@@ -22,12 +22,12 @@ import com.juick.Tag;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
*/
public class MessageSerializer extends JSONSerializer<Message> {
- private final static Logger LOGGER = Logger.getLogger(MessageSerializer.class.getName());
+ private final static Logger LOGGER = LoggerFactory.getLogger(MessageSerializer.class);
UserSerializer userSerializer = new UserSerializer();
PlaceSerializer placeSerializer = new PlaceSerializer();
@@ -133,7 +133,7 @@ public class MessageSerializer extends JSONSerializer<Message> {
json.put("photo", photo);
}
} catch (JSONException e) {
- LOGGER.log(Level.SEVERE, "JSON Exception", e);
+ LOGGER.error("JSON Exception", e);
}
return json;
diff --git a/juick-core/src/main/resources/logback.xml b/juick-core/src/main/resources/logback.xml
new file mode 100644
index 00000000..9e3bf16c
--- /dev/null
+++ b/juick-core/src/main/resources/logback.xml
@@ -0,0 +1,13 @@
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+</configuration> \ No newline at end of file
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;
}
diff --git a/juick-demo/build.gradle b/juick-demo/build.gradle
index 16bf0c17..2807266d 100644
--- a/juick-demo/build.gradle
+++ b/juick-demo/build.gradle
@@ -15,6 +15,8 @@ repositories {
mainClassName = "com.juick.demo.Demo"
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':juick-core')
compile 'org.apache.commons:commons-lang3:3.5'
@@ -22,5 +24,6 @@ dependencies {
compile 'mysql:mysql-connector-java:5.1.39'
compile 'ch.vorburger.mariaDB4j:mariaDB4j:2.2.2'
compile 'jline:jline:2.14.2'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
}
compileJava.options.encoding = 'UTF-8' \ No newline at end of file
diff --git a/juick-demo/src/main/java/com/juick/demo/Demo.java b/juick-demo/src/main/java/com/juick/demo/Demo.java
index c3d45b44..0ed18079 100644
--- a/juick-demo/src/main/java/com/juick/demo/Demo.java
+++ b/juick-demo/src/main/java/com/juick/demo/Demo.java
@@ -12,6 +12,8 @@ import com.juick.server.protocol.JuickProtocol;
import com.juick.server.protocol.ProtocolReply;
import jline.UnsupportedTerminal;
import jline.console.ConsoleReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
@@ -19,13 +21,12 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.logging.Logger;
/**
* Created by vitalyster on 30.08.2016.
*/
public class Demo {
- private static final Logger logger = Logger.getLogger(Demo.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Demo.class);
public static void main(String ...args) throws ManagedProcessException {
DB db = DB.newEmbeddedDB(33306);
db.start();
diff --git a/juick-notifications/build.gradle b/juick-notifications/build.gradle
index f60edc49..b178758c 100644
--- a/juick-notifications/build.gradle
+++ b/juick-notifications/build.gradle
@@ -7,14 +7,16 @@ 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'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
compile 'com.ganyo:gcm-server:1.1.0'
compile 'com.notnoop.apns:apns:1.0.0.Beta6'
- def springFrameworkVersion = '4.3.4.RELEASE'
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-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java
index 7bb81530..12993418 100644
--- a/juick-notifications/src/main/java/com/juick/components/Notifications.java
+++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java
@@ -41,6 +41,8 @@ import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.http.util.TextUtils;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment;
@@ -55,8 +57,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
@@ -64,7 +64,7 @@ import java.util.logging.Logger;
*/
public class Notifications implements DisposableBean, Stream.StreamListener, MessageListener {
- private static Logger logger = Logger.getLogger(Notifications.class.getName());
+ private static Logger logger = LoggerFactory.getLogger(Notifications.class);
String wns_application_sip;
String wns_client_secret;
@@ -101,7 +101,7 @@ public class Notifications implements DisposableBean, Stream.StreamListener, Mes
xmpp.addListener((Stream.StreamListener) this);
xmpp.addListener((MessageListener) this);
} catch (IOException e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
+ logger.error(e.getMessage(), e);
}
}
@@ -111,7 +111,7 @@ public class Notifications implements DisposableBean, Stream.StreamListener, Mes
}
@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) {
@@ -144,9 +144,9 @@ public class Notifications implements DisposableBean, Stream.StreamListener, Mes
logger.info("RES " + i + ": " + results.get(i).toString());
}
} catch (IOException e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
+ logger.error(e.getMessage(), e);
} catch (IllegalArgumentException err) {
- logger.warning("Android: Invalid API Key");
+ logger.warn("Android: Invalid API Key");
}
} else {
logger.info("GMS: no recipients");
@@ -188,13 +188,13 @@ public class Notifications implements DisposableBean, Stream.StreamListener, Mes
+ "<command arguments=\"?mid=" + jmsg.getMID() + "\" />"
+ "</commands>"
+ "</toast>";
- logger.fine(xml);
+ logger.trace(xml);
for (String url : urls) {
logger.info("WNS: " + url);
sendWNS(wnsToken, url, xml);
}
} catch (IOException | IllegalStateException e) {
- logger.log(Level.SEVERE, "WNS: ", e);
+ logger.error("WNS: ", e);
}
}
diff --git a/juick-rss/build.gradle b/juick-rss/build.gradle
index 7339a587..b17a2c04 100644
--- a/juick-rss/build.gradle
+++ b/juick-rss/build.gradle
@@ -7,11 +7,14 @@ repositories {
mavenCentral()
}
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':juick-core')
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
compile 'org.apache.commons:commons-dbcp2:2.1.1'
compile 'org.apache.commons:commons-lang3:3.5'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
providedRuntime 'mysql:mysql-connector-java:5.1.39'
}
diff --git a/juick-ws/build.gradle b/juick-ws/build.gradle
index 6a796c02..727a3c7b 100644
--- a/juick-ws/build.gradle
+++ b/juick-ws/build.gradle
@@ -15,15 +15,17 @@ repositories {
mavenCentral()
}
+def slf4jVersion = '1.7.21'
+def springFrameworkVersion = '4.3.4.RELEASE'
+def jacksonVersion = '2.8.4'
+
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
- compile 'org.slf4j:slf4j-jdk14:1.7.21'
- def springFrameworkVersion = '4.3.4.RELEASE'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
compile "org.springframework:spring-jdbc:${springFrameworkVersion}"
compile "org.springframework:spring-webmvc:${springFrameworkVersion}"
compile "org.springframework:spring-websocket:${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-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
index 4a9373b3..5860426a 100644
--- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
+++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java
@@ -5,6 +5,8 @@ import com.juick.server.MessagesQueries;
import com.juick.server.UserQueries;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@@ -18,8 +20,6 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
* Created by vitalyster on 28.06.2016.
@@ -29,7 +29,8 @@ public class WebsocketComponent extends TextWebSocketHandler {
@Inject
JdbcTemplate jdbc;
- private static final Logger logger = Logger.getLogger(WebsocketComponent.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(WebsocketComponent.class);
+
final List<SocketSubscribed> clients = Collections.synchronizedList(new ArrayList<SocketSubscribed>());
@Override
@@ -55,7 +56,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
logger.info(String.format("wrong hash for %d from %s", visitor.getUID(), hXRealIP));
session.close(new CloseStatus(403, "Forbidden"));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
}
break;
@@ -90,7 +91,7 @@ public class WebsocketComponent extends TextWebSocketHandler {
try {
session.close(new CloseStatus(403, "Forbidden"));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
}
}
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
index 0f2f75f6..8dffd388 100644
--- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
+++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java
@@ -9,6 +9,8 @@ import com.juick.xmpp.Stream;
import com.juick.xmpp.StreamComponent;
import com.juick.xmpp.extensions.JuickMessage;
import org.apache.commons.lang3.math.NumberUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@@ -19,8 +21,6 @@ import java.io.IOException;
import java.net.Socket;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@@ -29,7 +29,8 @@ import java.util.stream.Collectors;
*/
@Component
public class XMPPConnection implements Stream.StreamListener, Message.MessageListener {
- private static final Logger logger = Logger.getLogger(XMPPConnection.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(XMPPConnection.class);
+
@Inject
JdbcTemplate sql;
ExecutorService service;
@@ -52,7 +53,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
xmpp.addListener((Message.MessageListener) this);
service.submit(() -> xmpp.startParsing());
} catch (IOException e) {
- logger.log(Level.SEVERE, "XMPPConnection error", e);
+ logger.error("XMPPConnection error", e);
}
}
@@ -64,7 +65,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
@Override
public void onStreamFail(Exception ex) {
- logger.log(Level.SEVERE, "XMPP stream failed", ex);
+ logger.error("XMPP stream failed", ex);
}
@Override
@@ -99,7 +100,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending pm to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}
@@ -118,7 +119,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending message to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
wsHandler.clients.stream().filter(c ->
@@ -128,7 +129,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending message to legacy client " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}
@@ -148,7 +149,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending reply to " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
wsHandler.clients.stream().filter(c ->
@@ -158,7 +159,7 @@ public class XMPPConnection implements Stream.StreamListener, Message.MessageLis
logger.info("sending reply to legacy client " + c.visitor.getUID());
c.session.sendMessage(new TextMessage(json));
} catch (IOException e) {
- logger.log(Level.WARNING, "ws error", e);
+ logger.warn("ws error", e);
}
});
}
diff --git a/juick-www/build.gradle b/juick-www/build.gradle
index b2f0ce8d..a901da09 100644
--- a/juick-www/build.gradle
+++ b/juick-www/build.gradle
@@ -26,6 +26,8 @@ repositories {
mavenCentral()
}
+def slf4jVersion = '1.7.21'
+
dependencies {
compile project(':juick-core')
compile project(':deps:com.juick.xmpp')
@@ -40,6 +42,7 @@ dependencies {
compile 'net.jodah:failsafe:0.9.5'
compile 'com.mitchellbosecke:pebble:2.2.3'
compile 'com.sun.mail:javax.mail:1.5.6'
+ compile 'org.slf4j:slf4j-api:${slf4jVersion}'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
providedRuntime 'mysql:mysql-connector-java:5.1.39'
}
@@ -53,3 +56,7 @@ gretty {
contextPath = ''
servletContainer = 'tomcat8'
}
+
+configurations {
+ all*.exclude module: 'commons-logging'
+}
diff --git a/juick-www/src/main/java/com/juick/www/FacebookLogin.java b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
index 5cecf1ef..2b67dd5c 100644
--- a/juick-www/src/main/java/com/juick/www/FacebookLogin.java
+++ b/juick-www/src/main/java/com/juick/www/FacebookLogin.java
@@ -19,6 +19,8 @@ package com.juick.www;
import com.juick.server.UserQueries;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -29,8 +31,6 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
@@ -38,7 +38,7 @@ import java.util.logging.Logger;
*/
public class FacebookLogin {
- private static final Logger logger = Logger.getLogger(FacebookLogin.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(FacebookLogin.class);
private final String FACEBOOK_APPID;
private final String FACEBOOK_SECRET;
@@ -76,7 +76,7 @@ public class FacebookLogin {
String token = Utils.fetchURL("https://graph.facebook.com/oauth/access_token?client_id=" + FACEBOOK_APPID + "&redirect_uri=" + URLEncoder.encode(FACEBOOK_REDIRECT, "utf-8") + "&client_secret=" + FACEBOOK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
if (token == null || token.isEmpty() || !token.startsWith("access_token=")) {
- logger.log(Level.SEVERE, "FACEBOOK TOKEN ERROR: " + token);
+ logger.error("FACEBOOK TOKEN ERROR: " + token);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -88,7 +88,7 @@ public class FacebookLogin {
String graph = Utils.fetchURL("https://graph.facebook.com/me?access_token=" + token);
if (graph == null || graph.isEmpty()) {
- logger.log(Level.SEVERE, "FACEBOOK GRAPH ERROR");
+ logger.error("FACEBOOK GRAPH ERROR");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -130,7 +130,7 @@ public class FacebookLogin {
throw new Exception();
}
} catch (Exception e) {
- logger.log(Level.WARNING, "fb error", e);
+ logger.error("fb error", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java
index d45f1a4b..aaa3e550 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -29,6 +29,8 @@ import com.juick.xmpp.extensions.XOOB;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.math.NumberUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
@@ -44,8 +46,6 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
@@ -53,7 +53,7 @@ import java.util.logging.Logger;
*/
public class NewMessage {
- private static final Logger logger = Logger.getLogger(NewMessage.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(NewMessage.class);
private String tmpDir, imgDir;
@@ -179,7 +179,7 @@ public class NewMessage {
try {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
- logger.log(Level.SEVERE, "MULTIPART ERROR", e);
+ logger.error("MULTIPART ERROR", e);
response.sendError(400);
return;
}
@@ -190,7 +190,7 @@ public class NewMessage {
URL imgUrl = new URL(paramImg);
attachmentFName = Utils.downloadImage(imgUrl);
} catch (Exception e) {
- logger.log(Level.SEVERE, "DOWNLOAD ERROR", e);
+ logger.error("DOWNLOAD ERROR", e);
response.sendError(500);
return;
}
@@ -257,7 +257,7 @@ public class NewMessage {
xmsg.to.Username = "jubo";
xmpp.send(xmsg);
} else {
- logger.log(Level.WARNING, "XMPP unavailable");
+ logger.warn("XMPP unavailable");
}
//
@@ -346,7 +346,7 @@ public class NewMessage {
try {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
- logger.log(Level.SEVERE, "MULTIPART ERROR", e);
+ logger.error("MULTIPART ERROR", e);
response.sendError(400);
return;
}
@@ -356,7 +356,7 @@ public class NewMessage {
try {
attachmentFName = Utils.downloadImage(new URL(paramImg));
} catch (Exception e) {
- logger.log(Level.SEVERE, "DOWNLOAD ERROR", e);
+ logger.error("DOWNLOAD ERROR", e);
response.sendError(500);
return;
}
@@ -415,7 +415,7 @@ public class NewMessage {
xmsg.to.Host = "push.juick.com";
xmpp.send(xmsg);
} else {
- logger.log(Level.WARNING, "XMPP unavailable");
+ logger.warn("XMPP unavailable");
}
Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew);
@@ -450,7 +450,7 @@ public class NewMessage {
xmsg.addChild(jmsg);
xmpp.send(xmsg);
} else {
- logger.log(Level.WARNING, "XMPP unavailable");
+ logger.warn("XMPP unavailable");
}
Utils.replyJSON(request, response, "{\"status\":\"ok\"}");
diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java
index 7380ca8f..f7a7f478 100644
--- a/juick-www/src/main/java/com/juick/www/PM.java
+++ b/juick-www/src/main/java/com/juick/www/PM.java
@@ -26,6 +26,8 @@ import com.juick.xmpp.Stream;
import com.juick.xmpp.extensions.JuickMessage;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
@@ -36,15 +38,13 @@ import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
* @author Ugnich Anton
*/
public class PM {
- private static final Logger logger = Logger.getLogger(PM.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(PM.class);
protected void doGetInbox(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException {
@@ -136,7 +136,7 @@ public class PM {
xmpp.send(mm);
}
} else {
- logger.log(Level.WARNING, "XMPP unavailable");
+ logger.warn("XMPP unavailable");
}
Utils.sendTemporaryRedirect(response, "/pm/sent");
diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java
index 48176ff9..f8873739 100644
--- a/juick-www/src/main/java/com/juick/www/PageTemplates.java
+++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java
@@ -23,6 +23,8 @@ import com.juick.server.MessagesQueries;
import com.juick.server.TagQueries;
import com.juick.server.UserQueries;
import org.apache.commons.lang3.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.StringUtils;
import ru.sape.Sape;
@@ -36,8 +38,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
/**
@@ -46,7 +46,8 @@ import java.util.stream.Collectors;
*/
public class PageTemplates {
- private static final Logger logger = Logger.getLogger(PageTemplates.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(PageTemplates.class);
+
public static Sape sape = null;
protected static final SimpleDateFormat sdfSQL = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat sdfSimple = new SimpleDateFormat("d MMM");
@@ -252,7 +253,7 @@ public class PageTemplates {
ret = sdfFull.format(fulldate);
}
} catch (Exception e) {
- logger.log(Level.SEVERE, "PARSE EXCEPTION: " + fulldate);
+ logger.error("PARSE EXCEPTION: " + fulldate);
}
}
return ret;
diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java
index 67f001b6..0d427efe 100644
--- a/juick-www/src/main/java/com/juick/www/Settings.java
+++ b/juick-www/src/main/java/com/juick/www/Settings.java
@@ -28,6 +28,8 @@ import com.mitchellbosecke.pebble.template.PebbleTemplate;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -53,8 +55,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -63,7 +63,7 @@ import java.util.stream.IntStream;
* @author Ugnich Anton
*/
public class Settings {
- private static final Logger logger = Logger.getLogger(Settings.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Settings.class);
private final String imgPath;
public Settings(String avatarsPath) {
@@ -218,7 +218,7 @@ public class Settings {
"<p><a href=\"/settings\">Back</a></p>";
} catch (MessagingException ex) {
- logger.log(Level.SEVERE, "mail exception", ex);
+ logger.error("mail exception", ex);
response.sendError(500);
return;
}
diff --git a/juick-www/src/main/java/com/juick/www/Utils.java b/juick-www/src/main/java/com/juick/www/Utils.java
index 4be659cb..c236ac62 100644
--- a/juick-www/src/main/java/com/juick/www/Utils.java
+++ b/juick-www/src/main/java/com/juick/www/Utils.java
@@ -19,6 +19,8 @@ package com.juick.www;
import com.juick.User;
import com.mitchellbosecke.pebble.PebbleEngine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.servlet.ServletException;
@@ -31,8 +33,6 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Paths;
import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -42,7 +42,8 @@ import java.util.regex.Pattern;
*/
public class Utils {
- private static final Logger logger = Logger.getLogger(Utils.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(Utils.class);
+
private static final PebbleEngine engine = new PebbleEngine.Builder().build();
private static String tmpDir = "/var/www/juick.com/i/tmp/";
@@ -153,7 +154,7 @@ public class Utils {
in.close();
return b.toString();
} catch (Exception e) {
- logger.log(Level.SEVERE, "fetchURL" , e);
+ logger.error("fetchURL" , e);
return null;
}
}
diff --git a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
index 7d718c9b..f0010ac8 100644
--- a/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
+++ b/juick-www/src/main/java/com/juick/www/VKontakteLogin.java
@@ -20,6 +20,8 @@ package com.juick.www;
import com.juick.server.UserQueries;
import org.json.JSONException;
import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -30,15 +32,13 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
/**
*
* @author Ugnich Anton
*/
public class VKontakteLogin {
- private static final Logger logger = Logger.getLogger(VKontakteLogin.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(VKontakteLogin.class);
private static final String VK_APPID = "3544101";
private static final String VK_SECRET = "z2afNI8jA5lIpZ2jsTm1";
private static final String VK_REDIRECT = "http://juick.com/_vklogin";
@@ -54,7 +54,7 @@ public class VKontakteLogin {
String tokenjson = Utils.fetchURL("https://oauth.vk.com/access_token?client_id=" + VK_APPID + "&redirect_uri=" + URLEncoder.encode(VK_REDIRECT, "utf-8") + "&client_secret=" + VK_SECRET + "&code=" + URLEncoder.encode(code, "utf-8"));
if (tokenjson == null || tokenjson.isEmpty()) {
- logger.log(Level.SEVERE, "VK TOKEN EMPTY");
+ logger.error("VK TOKEN EMPTY");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -65,12 +65,12 @@ public class VKontakteLogin {
token = json.getString("access_token");
vkID = json.getLong("user_id");
} catch (JSONException e) {
- logger.log(Level.SEVERE, "VK TOKEN EXCEPTION: ", e);
+ logger.error("VK TOKEN EXCEPTION: ", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
if (token == null || vkID == 0) {
- logger.log(Level.SEVERE, "VK TOKEN EMPTY: " + tokenjson);
+ logger.error("VK TOKEN EMPTY: " + tokenjson);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -79,7 +79,7 @@ public class VKontakteLogin {
String graph = Utils.fetchURL("https://api.vk.com/method/users.get?uids=" + vkID + "&fields=screen_name&access_token=" + token);
if (graph == null || graph.isEmpty()) {
- logger.log(Level.SEVERE, "VK GRAPH ERROR");
+ logger.error("VK GRAPH ERROR");
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
@@ -109,7 +109,7 @@ public class VKontakteLogin {
response.setHeader("Location", "/signup?type=vk&hash=" + loginhash);
}
} catch (Exception e) {
- logger.log(Level.SEVERE, "JSON ERROR", e);
+ logger.error("JSON ERROR", e);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
diff --git a/juick-www/src/main/java/ru/sape/SapeConnection.java b/juick-www/src/main/java/ru/sape/SapeConnection.java
index 99a89302..5c2e3397 100644
--- a/juick-www/src/main/java/ru/sape/SapeConnection.java
+++ b/juick-www/src/main/java/ru/sape/SapeConnection.java
@@ -1,6 +1,8 @@
package ru.sape;
import com.github.ooxi.phparser.SerializedPhpParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
@@ -10,11 +12,9 @@ import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class SapeConnection {
- private static final Logger logger = Logger.getLogger(SapeConnection.class.getName());
+ private static final Logger logger = LoggerFactory.getLogger(SapeConnection.class);
private final String version = "1.0.3";
private final List<String> serverList = Arrays.asList("dispenser-01.sape.ru", "dispenser-02.sape.ru");
private final String dispenserPath;
@@ -81,7 +81,7 @@ public class SapeConnection {
}
if (data.startsWith("FATAL ERROR:")) {
- logger.log(Level.SEVERE, "Sape responded with error: " + data);
+ logger.error("Sape responded with error: " + data);
continue;
}
@@ -89,7 +89,7 @@ public class SapeConnection {
try {
cached = (Map<String, Object>) new SerializedPhpParser(data).parse();
} catch (Exception e) {
- logger.log(Level.SEVERE, "Can't parse Sape data", e);
+ logger.error("Can't parse Sape data", e);
continue;
}
@@ -98,7 +98,7 @@ public class SapeConnection {
return cached;
}
- logger.log(Level.SEVERE, "Unable to fetch Sape data");
+ logger.error("Unable to fetch Sape data");
return Collections.emptyMap();
}
diff --git a/juick-www/src/main/webapp/WEB-INF/logging.properties.example b/juick-www/src/main/webapp/WEB-INF/logging.properties.example
deleted file mode 100644
index 7bdaa72e..00000000
--- a/juick-www/src/main/webapp/WEB-INF/logging.properties.example
+++ /dev/null
@@ -1,5 +0,0 @@
-handlers = java.util.logging.FileHandler
-java.util.logging.FileHandler.pattern = www.log
-java.util.logging.FileHandler.limit = 1000000
-java.util.logging.FileHandler.count = 5
-java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
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);
}
}
}