annotate src/goodjava/webserver/handlers/LogHandler.java @ 1461:e5d48b85351c

start lucene.logging
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 28 Mar 2020 21:30:42 -0600
parents 27efb1fcbcb5
children 329197048ff0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1402
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
1 package goodjava.webserver.handlers;
1138
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
1402
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
3 import goodjava.logging.Logger;
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
4 import goodjava.logging.LoggerFactory;
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
5 import goodjava.webserver.Handler;
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
6 import goodjava.webserver.Request;
27efb1fcbcb5 move luan.lib to goodjava
Franklin Schmidt <fschmidt@gmail.com>
parents: 1347
diff changeset
7 import goodjava.webserver.Response;
1138
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 public final class LogHandler implements Handler {
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 private static final Logger logger = LoggerFactory.getLogger("HTTP");
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 private final Handler handler;
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 public LogHandler(Handler handler) {
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 this.handler = handler;
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 }
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 public Response handle(Request request) {
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 Response response = handler.handle(request);
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 logger.info( request.method + " " + request.path + " " + response.status.code + " " + response.body.length );
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 return response;
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 }
4189027691b7 webserver - add LogHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 }