Esempio n. 1
0
 public static void prettyFormatResponseToLog(
     @NotNull Logger logger, @NotNull HttpResponse response) {
   if (logger.isDebugEnabled()) {
     try {
       String content = ResponseUtil.getResponseContentAsString(response);
       org.apache.http.Header header = response.getEntity().getContentType();
       String contentType =
           header == null ? "text/plain" : header.getElements()[0].getName().toLowerCase();
       if (contentType.contains("xml")) {
         prettyFormatXmlToLog(logger, content);
       } else if (contentType.contains("json")) {
         prettyFormatJsonToLog(logger, content);
       } else {
         logger.debug(content);
       }
     } catch (IOException e) {
       logger.error(e);
     }
   }
 }
Esempio n. 2
0
 public static void prettyFormatResponseToLog(
     @NotNull Logger logger, @NotNull HttpMethod response) {
   if (logger.isDebugEnabled() && response.hasBeenUsed()) {
     try {
       String content = ResponseUtil.getResponseContentAsString(response);
       Header header = response.getRequestHeader(HTTP.CONTENT_TYPE);
       String contentType =
           header == null ? "text/plain" : header.getElements()[0].getName().toLowerCase();
       if (contentType.contains("xml")) {
         prettyFormatXmlToLog(logger, content);
       } else if (contentType.contains("json")) {
         prettyFormatJsonToLog(logger, content);
       } else {
         logger.debug(content);
       }
     } catch (IOException e) {
       logger.error(e);
     }
   }
 }