diff src/goodjava/webserver/handlers/LogHandler.java @ 1402:27efb1fcbcb5

move luan.lib to goodjava
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 17 Sep 2019 01:35:01 -0400
parents src/luan/lib/webserver/handlers/LogHandler.java@643cf1c37723
children 329197048ff0
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/goodjava/webserver/handlers/LogHandler.java	Tue Sep 17 01:35:01 2019 -0400
@@ -0,0 +1,24 @@
+package goodjava.webserver.handlers;
+
+import goodjava.logging.Logger;
+import goodjava.logging.LoggerFactory;
+import goodjava.webserver.Handler;
+import goodjava.webserver.Request;
+import goodjava.webserver.Response;
+
+
+public final class LogHandler implements Handler {
+	private static final Logger logger = LoggerFactory.getLogger("HTTP");
+
+	private final Handler handler;
+
+	public LogHandler(Handler handler) {
+		this.handler = handler;
+	}
+
+	public Response handle(Request request) {
+		Response response = handler.handle(request);
+		logger.info( request.method + " " + request.path + " " + response.status.code + " " + response.body.length );
+		return response;
+	}
+}