view src/goodjava/webserver/handlers/LogHandler.java @ 1528:3bd4d7963456

use goodjava/lucene/api
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 26 Jul 2020 23:11:53 -0600
parents 27efb1fcbcb5
children 329197048ff0
line wrap: on
line source

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;
	}
}