aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core
diff options
context:
space:
mode:
authorvempo <vitaliy.emporopulo@amdocs.com>2018-08-06 16:21:01 +0300
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-08-06 16:09:04 +0000
commit44651d903d83f9256c324ec2a3c8886e91e1e433 (patch)
tree0e1961ce6c69dcb8eb18cf8b4e8af1e5eed6e3b4 /openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core
parent1ecdbf74427467327de0b1e11cd0a839d6dc05bd (diff)
Minor improvements to logging for servlets
Fixed import order, more resilient statuses for Spring, cleaner code and tests, more convenient APIs. Change-Id: I6493c81d9c3c1c543c354562e074876268794438 Issue-ID: SDC-1580 Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MDCDelegate.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggingServiceProvider.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java4
8 files changed, 14 insertions, 20 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java
index b4abb8b368..fb0ceb97e2 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/DispatchingAppender.java
@@ -24,11 +24,10 @@ import ch.qos.logback.core.Appender;
import ch.qos.logback.core.AppenderBase;
import ch.qos.logback.core.joran.spi.DefaultClass;
import ch.qos.logback.core.sift.Discriminator;
-import org.slf4j.LoggerFactory;
-
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.slf4j.LoggerFactory;
/**
* <p>Allows to use EELF logging configuration almost as is, by using a custom routing function, but pre-configured
@@ -55,7 +54,7 @@ public class DispatchingAppender extends AppenderBase<ILoggingEvent> {
// "magic" appender to indicate a missing appender
private static final Appender<ILoggingEvent> NO_APPENDER = new DispatchingAppender();
- private Map<String, Appender<ILoggingEvent>> appenders = new ConcurrentHashMap<>();
+ private final Map<String, Appender<ILoggingEvent>> appenders = new ConcurrentHashMap<>();
private Discriminator<ILoggingEvent> discriminator;
private String appenderNamePattern;
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
index 3370ebfaf3..f6e933d57b 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/GlobalContextProvider.java
@@ -16,13 +16,12 @@
package org.openecomp.sdc.logging.slf4j;
-import org.openecomp.sdc.logging.context.HostAddressCache;
-import org.openecomp.sdc.logging.context.InstanceId;
-
import java.net.InetAddress;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
+import org.openecomp.sdc.logging.context.HostAddressCache;
+import org.openecomp.sdc.logging.context.InstanceId;
/**
* Maps global logging context to corresponding MDC fields.
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MDCDelegate.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MDCDelegate.java
index 9c9410c764..026d3fa99b 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MDCDelegate.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MDCDelegate.java
@@ -16,10 +16,9 @@
package org.openecomp.sdc.logging.slf4j;
-import org.slf4j.MDC;
-
import java.util.EnumMap;
import java.util.Map;
+import org.slf4j.MDC;
/**
* Because we don't know which information should be carried over from MDC, and which shouldn't, copy just the keys that
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java
index 7d2d846097..17439da161 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java
@@ -41,10 +41,10 @@ import org.slf4j.MarkerFactory;
*/
public class Markers {
+ public static final Marker AUDIT = MarkerFactory.getMarker("AUDIT");
+ public static final Marker METRICS = MarkerFactory.getMarker("METRICS");
+
private Markers() {
// prevent instantiation
}
-
- public static final Marker AUDIT = MarkerFactory.getMarker("AUDIT");
- public static final Marker METRICS = MarkerFactory.getMarker("METRICS");
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java
index 6a74b704de..40684cc132 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java
@@ -16,10 +16,9 @@
package org.openecomp.sdc.logging.slf4j;
-import org.openecomp.sdc.logging.api.ContextData;
-
import java.util.EnumMap;
import java.util.Map;
+import org.openecomp.sdc.logging.api.ContextData;
/**
* Maps request data sent to the context service to corresponding MDC fields.
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
index 248ad43ca8..fbb5fbf1f2 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java
@@ -16,14 +16,13 @@
package org.openecomp.sdc.logging.slf4j;
+import java.text.SimpleDateFormat;
import org.openecomp.sdc.logging.api.AuditData;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.MetricsData;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import java.text.SimpleDateFormat;
-
/**
* Delegates log calls to SLF4J API and MDC.
*
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggingServiceProvider.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggingServiceProvider.java
index c18716843d..9d4d507ac5 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggingServiceProvider.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggingServiceProvider.java
@@ -16,13 +16,12 @@
package org.openecomp.sdc.logging.slf4j;
+import java.util.Objects;
+import java.util.concurrent.Callable;
import org.openecomp.sdc.logging.api.ContextData;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.spi.LoggingServiceProvider;
-import java.util.Objects;
-import java.util.concurrent.Callable;
-
/**
* Uses SLF4J as backend for logging service.
*
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
index 73dd25ccae..f2f0c1d674 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java
@@ -265,8 +265,8 @@ public class SLF4JLoggerWrapperTest {
// build a dynamic proxy to avoid implementing the long list of Logger methods
// when we actually need just Logger.info() with the audit marker
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- return SpyLogger.class.cast(
- Proxy.newProxyInstance(classLoader, new Class<?>[]{SpyLogger.class}, new SpyingInvocationHandler()));
+ return (SpyLogger) Proxy.newProxyInstance(classLoader, new Class<?>[] {SpyLogger.class},
+ new SpyingInvocationHandler());
}
private static class SpyingInvocationHandler implements InvocationHandler {