more logging

This commit is contained in:
Claudio Atzori 2021-02-25 12:29:18 +01:00
parent 271e88537b
commit dc98c39500
1 changed files with 12 additions and 9 deletions

View File

@ -1,6 +1,9 @@
package eu.dnetlib.dhp.common.rest; package eu.dnetlib.dhp.common.rest;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
@ -9,13 +12,10 @@ import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays; import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.stream.Collectors;
public class DNetRestClient { public class DNetRestClient {
@ -53,8 +53,11 @@ public class DNetRestClient {
CloseableHttpClient client = HttpClients.createDefault(); CloseableHttpClient client = HttpClients.createDefault();
log.info("performing HTTP request, method {} on URI {}", r.getMethod(), r.getURI().toString()); log.info("performing HTTP request, method {} on URI {}", r.getMethod(), r.getURI().toString());
log.info("request headers: {}", log
Arrays.asList(r.getAllHeaders()) .info(
"request headers: {}",
Arrays
.asList(r.getAllHeaders())
.stream() .stream()
.map(h -> h.getName() + ":" + h.getValue()) .map(h -> h.getName() + ":" + h.getValue())
.collect(Collectors.joining(","))); .collect(Collectors.joining(",")));