mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-25 01:21:41 +01:00
Configuration options for logging request headers to console
This commit is contained in:
parent
bb6dc692cd
commit
58eae50428
@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.webserver.configuration;
|
||||
import com.djrapitops.plan.delivery.webserver.auth.AllowedIpList;
|
||||
import com.djrapitops.plan.delivery.webserver.http.AccessAddressPolicy;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.PluginSettings;
|
||||
import com.djrapitops.plan.settings.config.paths.WebserverSettings;
|
||||
import com.djrapitops.plan.storage.file.PlanFiles;
|
||||
|
||||
@ -48,6 +49,10 @@ public class WebserverConfiguration {
|
||||
return webserverLogMessages;
|
||||
}
|
||||
|
||||
public boolean isDevMode() {
|
||||
return config.isTrue(PluginSettings.DEV_MODE);
|
||||
}
|
||||
|
||||
public boolean logAccessToConsole() {
|
||||
return config.isTrue(WebserverSettings.LOG_ACCESS_TO_CONSOLE);
|
||||
}
|
||||
|
@ -54,6 +54,9 @@ public class AccessLogger {
|
||||
getRequestURI(internalRequest, request) +
|
||||
" (from " + internalRequest.getAccessAddress(webserverConfiguration) + ") - " +
|
||||
code;
|
||||
if (webserverConfiguration.isDevMode()) {
|
||||
message += " Request Headers" + internalRequest.getRequestHeaders();
|
||||
}
|
||||
|
||||
int codeFamily = code - (code % 100); // 5XX, 4XX etc
|
||||
switch (codeFamily) {
|
||||
|
@ -26,6 +26,7 @@ import com.djrapitops.plan.delivery.webserver.configuration.WebserverConfigurati
|
||||
import com.djrapitops.plan.utilities.dev.Untrusted;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -54,6 +55,8 @@ public interface InternalRequest {
|
||||
|
||||
Request toRequest();
|
||||
|
||||
Map<String, String> getRequestHeaders();
|
||||
|
||||
List<Cookie> getCookies();
|
||||
|
||||
String getMethod();
|
||||
|
@ -81,7 +81,8 @@ public class JettyInternalRequest implements InternalRequest {
|
||||
return new com.djrapitops.plan.delivery.web.resolver.request.Request(requestMethod, path, query, user, headers, requestBody);
|
||||
}
|
||||
|
||||
private Map<String, String> getRequestHeaders() {
|
||||
@Override
|
||||
public Map<String, String> getRequestHeaders() {
|
||||
return streamHeaderNames()
|
||||
.collect(Collectors.toMap(Function.identity(), baseRequest::getHeader,
|
||||
(one, two) -> one + ';' + two));
|
||||
|
Loading…
Reference in New Issue
Block a user