From ddffdd6102676dce84793d288dbab392c701ede5 Mon Sep 17 00:00:00 2001 From: Ryan Aird Date: Sat, 3 Oct 2020 20:39:26 -0600 Subject: [PATCH] Split logging into separate function and use tabs instead of spaces' --- .../core/webserver/HttpConnection.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/HttpConnection.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/HttpConnection.java index 33805d25..8af9ca47 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/HttpConnection.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/webserver/HttpConnection.java @@ -72,20 +72,9 @@ public void run() { HttpRequest request = acceptRequest(); HttpResponse response = handler.handle(request); sendResponse(response); - if (verbose) { - DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); - Date date = new Date(); - Logger.global.logInfo( - connection.getInetAddress().toString() + - " [ " + - dateFormat.format(date) + - " ] \"" + - request.getMethod() + - " " + request.getPath() + - " " + request.getVersion() + - "\" " + - response.getStatusCode().toString()); - } + if (verbose) { + log(request, response); + } } catch (InvalidRequestException e){ try { sendResponse(new HttpResponse(HttpStatusCode.BAD_REQUEST)); @@ -109,6 +98,21 @@ public void run() { Logger.global.logError("Error while closing HttpConnection!", e); } } + + private void log(HttpRequest request, HttpResponse response) { + DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + Date date = new Date(); + Logger.global.logInfo( + connection.getInetAddress().toString() + + " [ " + + dateFormat.format(date) + + " ] \"" + + request.getMethod() + + " " + request.getPath() + + " " + request.getVersion() + + "\" " + + response.getStatusCode().toString()); + } private void sendResponse(HttpResponse response) throws IOException { response.write(out);