From d6fb4288688294d2f76325f14410db3091fea0fa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 11 Jul 2016 12:25:03 +0300 Subject: logging --- juick-api/src/main/java/com/juick/api/Main.java | 8 ++++---- juick-api/src/main/java/com/juick/api/Messages.java | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'juick-api/src') 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 afd7c11c..03c97435 100644 --- a/juick-api/src/main/java/com/juick/api/Main.java +++ b/juick-api/src/main/java/com/juick/api/Main.java @@ -253,7 +253,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { try { attachmentFName = Utils.receiveMultiPartFile(request, "attach"); } catch (Exception e) { - System.out.println("MULTIPART ERROR: " + e.toString()); + log("MULTIPART ERROR", e); response.sendError(400); return; } @@ -264,7 +264,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { URL imgUrl = new URL(paramImg); attachmentFName = Utils.downloadImage(imgUrl); } catch (Exception e) { - System.out.println("DOWNLOAD ERROR: " + e.toString()); + log("DOWNLOAD ERROR", e); response.sendError(500); return; } @@ -369,7 +369,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { try { attachmentFName = Utils.receiveMultiPartFile(request, "attach"); } catch (Exception e) { - System.out.println("MULTIPART ERROR: " + e.toString()); + log("MULTIPART ERROR", e); response.sendError(400); return; } @@ -379,7 +379,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { try { attachmentFName = Utils.downloadImage(new URL(paramImg)); } catch (Exception e) { - System.out.println("DOWNLOAD ERROR: " + e.toString()); + log("DOWNLOAD ERROR", e); response.sendError(500); return; } 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 b7131c31..ad8d82e0 100644 --- a/juick-api/src/main/java/com/juick/api/Messages.java +++ b/juick-api/src/main/java/com/juick/api/Messages.java @@ -18,6 +18,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -25,6 +27,8 @@ import java.util.List; */ public class Messages { + private static final Logger logger = Logger.getLogger(Messages.class.getName()); + JdbcTemplate sql; MessageSerializer messageSerializer = new MessageSerializer(); @@ -178,7 +182,7 @@ public class Messages { throw new Exception("Message not found"); } } catch (Exception e) { - System.err.println("SETPOPULAR ERROR: " + e.toString()); + logger.log(Level.SEVERE, "SETPOPULAR ERROR", e); } } -- cgit v1.2.3