mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-07 16:58:16 +01:00
Use string-builder in verbose logger
This commit is contained in:
parent
4141d21a70
commit
8f97b08eb5
@ -24,24 +24,25 @@ public LoggingRequestHandler(HttpRequestHandler delegate, Logger logger) {
|
||||
public HttpResponse handle(HttpRequest request) {
|
||||
String source = request.getSource().toString();
|
||||
|
||||
HttpHeader xffHeader = request.getHeader("x-forwarded-for");
|
||||
HttpHeader xffHeader = request.getHeader("X-Forwarded-For");
|
||||
if (xffHeader != null && !xffHeader.getValues().isEmpty()) {
|
||||
source = xffHeader.getValues().get(0);
|
||||
}
|
||||
|
||||
String log = source + " \""
|
||||
+ request.getMethod()
|
||||
+ " " + request.getAddress()
|
||||
+ " " + request.getVersion()
|
||||
+ "\" ";
|
||||
StringBuilder log = new StringBuilder()
|
||||
.append(source)
|
||||
.append(" \"").append(request.getMethod())
|
||||
.append(" ").append(request.getAddress())
|
||||
.append(" ").append(request.getVersion())
|
||||
.append("\" ");
|
||||
|
||||
HttpResponse response = delegate.handle(request);
|
||||
|
||||
log += response.getStatusCode().toString();
|
||||
log.append(response.getStatusCode());
|
||||
if (response.getStatusCode().getCode() < 400) {
|
||||
logger.logInfo(log);
|
||||
logger.logInfo(log.toString());
|
||||
} else {
|
||||
logger.logWarning(log);
|
||||
logger.logWarning(log.toString());
|
||||
}
|
||||
|
||||
return response;
|
||||
|
Loading…
Reference in New Issue
Block a user