aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2019-09-10 16:31:01 +0300
committerEylon Malin <eylon.malin@intl.att.com>2019-09-12 08:51:25 +0300
commit2265215c803291e029add2db7912c7b1e25e0a8e (patch)
tree3082c232fa26483a0f1262efcc5c228d554280d1 /vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
parent77e77f77c89ca1bef622b12c71897ab1ab256216 (diff)
make Logging a service and inject it to SyncRestClient
Issue-ID: VID-611 Change-Id: I120782884351c55b2e0d1b4ca8bae1e2479d1d0a Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/utils/Logging.java')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/utils/Logging.java39
1 files changed, 18 insertions, 21 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
index 71478fcf1..77b7ee869 100644
--- a/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
+++ b/vid-app-common/src/main/java/org/onap/vid/utils/Logging.java
@@ -20,37 +20,34 @@
package org.onap.vid.utils;
+import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCause;
+import static org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList;
+import static org.onap.vid.utils.Streams.not;
+
import com.att.eelf.configuration.EELFLogger;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.collect.ImmutableList;
import io.joshworks.restclient.http.HttpResponse;
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.UUID;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
-import org.onap.vid.exceptions.GenericUncheckedException;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.exceptions.GenericUncheckedException;
import org.springframework.http.HttpMethod;
+import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.ProcessingException;
-import javax.ws.rs.core.Response;
-import java.util.Arrays;
-import java.util.Optional;
-import java.util.UUID;
-
-import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCause;
-import static org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList;
-import static org.onap.vid.utils.Streams.not;
-
+@Service
public class Logging {
- private Logging() {
- }
-
public static final String HTTP_REQUESTS_OUTGOING = "http.requests.outgoing.";
public static final String REQUEST_ID_HEADER_KEY = SystemProperties.ECOMP_REQUEST_ID;
@@ -84,7 +81,7 @@ public class Logging {
return EELFLoggerDelegate.getLogger(HTTP_REQUESTS_OUTGOING +serverName);
}
- public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
+ public void logRequest(final EELFLogger logger, final HttpMethod method, final String url, final Object body) {
if (!logger.isDebugEnabled()) {
return;
}
@@ -103,11 +100,11 @@ public class Logging {
}
}
- public static void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
+ public void logRequest(final EELFLogger logger, final HttpMethod method, final String url) {
logger.debug("Sending {} {}", method.name(), url);
}
- public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
+ public <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response, final Class<T> entityClass) {
if (!logger.isDebugEnabled()) {
return;
}
@@ -124,7 +121,7 @@ public class Logging {
}
}
- public static <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) {
+ public <T> void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final HttpResponse<T> response) {
try {
logger.debug("Received {} {} Status: {} . Body: {}", method.name(), url, response.getStatus(), response.getBody());
}
@@ -133,7 +130,7 @@ public class Logging {
}
}
- public static void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
+ public void logResponse(final EELFLogger logger, final HttpMethod method, final String url, final Response response) {
logResponse(logger, method, url, response, String.class);
}