use of com.dtflys.forest.logging.RequestLogMessage in project forest by dromara.
the class AbstractHttpclientRequestSender method logRequest.
public <T extends HttpRequestBase> void logRequest(int retryCount, T httpReq) {
LogConfiguration logConfiguration = request.getLogConfiguration();
if (!logConfiguration.isLogEnabled() || !logConfiguration.isLogRequest()) {
return;
}
RequestLogMessage logMessage = getRequestLogMessage(retryCount, httpReq);
logMessage.setRequest(request);
request.setRequestLogMessage(logMessage);
ForestLogHandler logHandler = request.getLogConfiguration().getLogHandler();
if (logHandler != null) {
logHandler.logRequest(logMessage);
}
}
use of com.dtflys.forest.logging.RequestLogMessage in project forest by dromara.
the class OkHttp3Executor method logRequest.
public void logRequest(int retryCount, Request okRequest, OkHttpClient okHttpClient) {
LogConfiguration logConfiguration = request.getLogConfiguration();
if (!logConfiguration.isLogEnabled() || !logConfiguration.isLogRequest()) {
return;
}
RequestLogMessage logMessage = buildRequestMessage(retryCount, okRequest);
logMessage.setRequest(request);
logMessage.setRetryCount(retryCount);
Proxy proxy = okHttpClient.proxy();
if (proxy != null) {
RequestProxyLogMessage proxyLogMessage = new RequestProxyLogMessage();
SocketAddress address = proxy.address();
if (address instanceof InetSocketAddress) {
InetSocketAddress inetSocketAddress = (InetSocketAddress) address;
proxyLogMessage.setHost(inetSocketAddress.getHostString());
proxyLogMessage.setPort(inetSocketAddress.getPort() + "");
logMessage.setProxy(proxyLogMessage);
}
}
request.setRequestLogMessage(logMessage);
logConfiguration.getLogHandler().logRequest(logMessage);
}
use of com.dtflys.forest.logging.RequestLogMessage in project forest by dromara.
the class OkHttp3Executor method buildRequestMessage.
protected RequestLogMessage buildRequestMessage(int retryCount, Request okRequest) {
RequestLogMessage message = new RequestLogMessage();
HttpUrl url = okRequest.url();
String scheme = url.scheme().toUpperCase();
String uri = url.uri().toString();
String method = okRequest.method();
message.setUri(uri);
message.setType(method);
message.setScheme(scheme);
message.setRetryCount(retryCount);
setLogHeaders(message, okRequest);
setLogBody(message, okRequest);
return message;
}
use of com.dtflys.forest.logging.RequestLogMessage in project forest by dromara.
the class AbstractHttpclientRequestSender method getRequestLogMessage.
private <T extends HttpRequestBase> RequestLogMessage getRequestLogMessage(int retryCount, T httpReq) {
RequestLogMessage logMessage = new RequestLogMessage();
URI uri = httpReq.getURI();
logMessage.setUri(uri.toASCIIString());
logMessage.setType(httpReq.getMethod());
logMessage.setScheme(uri.getScheme());
logMessage.setRetryCount(retryCount);
setLogHeaders(logMessage, httpReq);
setLogBody(logMessage, httpReq);
ForestProxy proxy = request.getProxy();
if (proxy != null) {
RequestProxyLogMessage proxyLogMessage = new RequestProxyLogMessage();
proxyLogMessage.setHost(proxy.getHost());
proxyLogMessage.setPort(proxy.getPort() + "");
logMessage.setProxy(proxyLogMessage);
}
return logMessage;
}
Aggregations