use of com.dtflys.forest.logging.RequestProxyLogMessage 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.RequestProxyLogMessage 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