[Swift-commit] r7012 - trunk/src/org/griphyn/vdl/karajan/monitor/monitors/http

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Tue Aug 27 18:39:24 CDT 2013


Author: hategan
Date: 2013-08-27 18:39:24 -0500 (Tue, 27 Aug 2013)
New Revision: 7012

Modified:
   trunk/src/org/griphyn/vdl/karajan/monitor/monitors/http/HTTPServer.java
Log:
log HTTP errors

Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/http/HTTPServer.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/http/HTTPServer.java	2013-08-27 05:45:56 UTC (rev 7011)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/http/HTTPServer.java	2013-08-27 23:39:24 UTC (rev 7012)
@@ -45,8 +45,7 @@
 import org.griphyn.vdl.karajan.monitor.SystemState;
 
 public class HTTPServer implements Runnable {
-    public static final Logger logger = Logger
-            .getLogger(HTTPServer.class);
+    public static final Logger logger = Logger.getLogger(HTTPServer.class);
 
     public static final String WEB_DIR = "httpmonitor/";
     
@@ -129,8 +128,7 @@
                 connectionProcessor.addChannel(s);
             }
             catch (Exception e) {
-                logger.info("Caught exception in coaster bootstrap service",
-                        e);
+                logger.info("Caught exception in HTTP monitor service", e);
             }
         }
     }
@@ -278,7 +276,7 @@
                         else {
                             int ix = line.indexOf(":");
                             if (ix == -1) {
-                                sendError("400 Bad request", null);
+                                sendError(line, "400 Bad request", null);
                                 break;
                             }
                             else {
@@ -348,16 +346,16 @@
                     createFileBuffer(page, cgiParams);
                 }
                 else {
-                    sendError("404 Not Found", ERROR_NOTFOUND);
+                    sendError(cmd, "404 Not Found", ERROR_NOTFOUND);
                 }
                 key.interestOps(SelectionKey.OP_WRITE);
             }
             else {
-                sendError("400 Bad Request", ERROR_BAD_REQUEST);
+                sendError(cmd, "400 Bad Request", ERROR_BAD_REQUEST);
             }
         }
 
-        private void sendError(String error, String html) {
+        private void sendError(String request, String error, String html) {
             state = SENDING_ERROR;
             List<ByteBuffer> l = new LinkedList<ByteBuffer>();
             addReply(l, "HTTP/1.1 " + error + "\n");
@@ -372,6 +370,7 @@
                 addReply(l, html);
             }
             replies = l.iterator();
+            logger.info(request + " - ERROR: " + error);
         }
 
         private void sendHeader(long len, String contentType) {
@@ -399,7 +398,7 @@
                     sdata = stateKeys.get(file).getData(params);
                 }
                 catch (Exception e) {
-                    sendError("500 Internal Server Error", 
+                    sendError("GET " + file, "500 Internal Server Error", 
                         processTemplate(ERROR_INTERNAL, e.toString(), getStackTrace(e)));
                     e.printStackTrace();
                     return;
@@ -410,7 +409,7 @@
             else {
                 URL url = loader.getResource(WEB_DIR + file);
                 if (url == null) {
-                    sendError("404 Not Found", ERROR_NOTFOUND);
+                    sendError("GET " + file, "404 Not Found", ERROR_NOTFOUND);
                 }
                 else {
                     try {
@@ -421,7 +420,7 @@
                     }
                     catch (Exception e) {
                         e.printStackTrace();
-                        sendError("500 Internal Server Error", 
+                        sendError("GET " + file, "500 Internal Server Error", 
                             processTemplate(ERROR_INTERNAL, e.toString(), getStackTrace(e)));
                     }
                 }




More information about the Swift-commit mailing list