aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com/juick/www
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-www/src/main/java/com/juick/www
parent705d4f87c97dfa20eb6daa88b93ff124fa401b92 (diff)
using slf4j + logback for logging
Diffstat (limited to 'juick-www/src/main/java/com/juick/www')
-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
7 files changed, 42 insertions, 40 deletions
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);
}
}