mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-29 22:13:48 +01:00
Split logging into separate function and use tabs instead of spaces'
This commit is contained in:
parent
a2579f307f
commit
ddffdd6102
@ -72,20 +72,9 @@ public void run() {
|
|||||||
HttpRequest request = acceptRequest();
|
HttpRequest request = acceptRequest();
|
||||||
HttpResponse response = handler.handle(request);
|
HttpResponse response = handler.handle(request);
|
||||||
sendResponse(response);
|
sendResponse(response);
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
log(request, response);
|
||||||
Date date = new Date();
|
}
|
||||||
Logger.global.logInfo(
|
|
||||||
connection.getInetAddress().toString() +
|
|
||||||
" [ " +
|
|
||||||
dateFormat.format(date) +
|
|
||||||
" ] \"" +
|
|
||||||
request.getMethod() +
|
|
||||||
" " + request.getPath() +
|
|
||||||
" " + request.getVersion() +
|
|
||||||
"\" " +
|
|
||||||
response.getStatusCode().toString());
|
|
||||||
}
|
|
||||||
} catch (InvalidRequestException e){
|
} catch (InvalidRequestException e){
|
||||||
try {
|
try {
|
||||||
sendResponse(new HttpResponse(HttpStatusCode.BAD_REQUEST));
|
sendResponse(new HttpResponse(HttpStatusCode.BAD_REQUEST));
|
||||||
@ -110,6 +99,21 @@ public void run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
private void sendResponse(HttpResponse response) throws IOException {
|
||||||
response.write(out);
|
response.write(out);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user