aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src')
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/Markers.java5
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/RequestContextProvider.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapper.java22
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/SLF4JLoggerWrapperTest.java34
12 files changed, 77 insertions, 55 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java
index b6f8cfa8ff..aa4657f83e 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminator.java
@@ -95,7 +95,7 @@ public class EventTypeDiscriminator extends AbstractDiscriminator<ILoggingEvent>
final Marker marker = event.getMarker();
if (marker != null) {
- if (marker.contains(Markers.AUDIT)) {
+ if (marker.contains(Markers.ENTRY) || marker.contains(Markers.EXIT)){
return AUDIT;
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
index 3e44a34722..c4e780fa8f 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/AuditField.java
@@ -16,6 +16,8 @@
package org.openecomp.sdc.logging.slf4j;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+
/**
* MDC fields that represent audit data.
*
@@ -24,13 +26,13 @@ package org.openecomp.sdc.logging.slf4j;
*/
enum AuditField implements MDCField {
- BEGIN_TIMESTAMP("BeginTimestamp"),
+ BEGIN_TIMESTAMP(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP),
END_TIMESTAMP("EndTimestamp"),
ELAPSED_TIME("ElapsedTime"),
- STATUS_CODE("StatusCode"),
- RESPONSE_CODE("ResponseCode"),
- RESPONSE_DESCRIPTION("ResponseDescription"),
- CLIENT_IP_ADDRESS("ClientIpAddress");
+ STATUS_CODE(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE),
+ RESPONSE_CODE(ONAPLogConstants.MDCs.RESPONSE_CODE),
+ RESPONSE_DESCRIPTION(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION),
+ CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS);
private final String key;
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java
index cce5f44863..87aa0e3a32 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/ContextField.java
@@ -16,6 +16,8 @@
package org.openecomp.sdc.logging.slf4j;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+
/**
* MDC fields that represent context data.
*
@@ -24,11 +26,11 @@ package org.openecomp.sdc.logging.slf4j;
*/
enum ContextField implements MDCField {
- REQUEST_ID("RequestId"),
- SERVICE_NAME("ServiceName"),
- PARTNER_NAME("PartnerName"),
- INSTANCE_ID("InstanceId"),
- SERVER("Server"),
+ REQUEST_ID(ONAPLogConstants.MDCs.REQUEST_ID),
+ SERVICE_NAME(ONAPLogConstants.MDCs.SERVICE_NAME),
+ PARTNER_NAME(ONAPLogConstants.MDCs.PARTNER_NAME),
+ INSTANCE_ID(ONAPLogConstants.MDCs.INSTANCE_UUID),
+ SERVER(ONAPLogConstants.MDCs.SERVER_FQDN),
SERVER_IP_ADDRESS("ServerIpAddress");
private final String key;
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 17439da161..3d9bbcfa53 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
@@ -16,6 +16,7 @@
package org.openecomp.sdc.logging.slf4j;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
@@ -41,7 +42,9 @@ import org.slf4j.MarkerFactory;
*/
public class Markers {
- public static final Marker AUDIT = MarkerFactory.getMarker("AUDIT");
+ public static final Marker ENTRY = MarkerFactory.getMarker(ONAPLogConstants.Markers.ENTRY.getName());
+ public static final Marker EXIT = MarkerFactory.getMarker(ONAPLogConstants.Markers.EXIT.getName());
+
public static final Marker METRICS = MarkerFactory.getMarker("METRICS");
private Markers() {
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java
index fda0c8b683..c4e8e143af 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/main/java/org/openecomp/sdc/logging/slf4j/MetricsField.java
@@ -16,6 +16,8 @@
package org.openecomp.sdc.logging.slf4j;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+
/**
* DC fields that represent metrics data.
*
@@ -24,15 +26,15 @@ package org.openecomp.sdc.logging.slf4j;
*/
public enum MetricsField implements MDCField {
- BEGIN_TIMESTAMP("BeginTimestamp"),
+ BEGIN_TIMESTAMP(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP),
END_TIMESTAMP("EndTimestamp"),
ELAPSED_TIME("ElapsedTime"),
- STATUS_CODE("StatusCode"),
- RESPONSE_CODE("ResponseCode"),
- RESPONSE_DESCRIPTION("ResponseDescription"),
- CLIENT_IP_ADDRESS("ClientIpAddress"),
+ STATUS_CODE(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE),
+ RESPONSE_CODE(ONAPLogConstants.MDCs.RESPONSE_CODE),
+ RESPONSE_DESCRIPTION(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION),
+ CLIENT_IP_ADDRESS(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS),
TARGET_VIRTUAL_ENTITY("TargetVirtualEntity"),
- TARGET_ENTITY("TargetEntity");
+ TARGET_ENTITY(ONAPLogConstants.MDCs.TARGET_ENTITY);
private final String key;
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 40684cc132..70e3dd6479 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
@@ -40,9 +40,9 @@ class RequestContextProvider implements ContextProvider {
static ContextData to(Map<ContextField, String> values) {
return ContextData.builder()
- .requestId(values.get(ContextField.REQUEST_ID))
- .serviceName(values.get(ContextField.SERVICE_NAME))
- .partnerName(values.get(ContextField.PARTNER_NAME)).build();
+ .requestId(values.get(ContextField.REQUEST_ID))
+ .serviceName(values.get(ContextField.SERVICE_NAME))
+ .partnerName(values.get(ContextField.PARTNER_NAME)).build();
}
@Override
@@ -58,7 +58,6 @@ class RequestContextProvider implements ContextProvider {
}
private void putIfNotNull(Map<ContextField, String> values, ContextField field, String value) {
-
if (value != null) {
values.put(field, value);
}
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 fbb5fbf1f2..f85a6bbe95 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
@@ -114,11 +114,11 @@ class SLF4JLoggerWrapper implements Logger {
@Override
public boolean isAuditEnabled() {
- return logger.isInfoEnabled(Markers.AUDIT);
+ return logger.isInfoEnabled(Markers.EXIT);
}
@Override
- public void audit(AuditData data) {
+ public void auditEntry(AuditData data) {
if (data == null) {
return; // not failing if null
@@ -126,7 +126,23 @@ class SLF4JLoggerWrapper implements Logger {
try {
putAuditOnMdc(data);
- logger.info(Markers.AUDIT, "");
+ logger.info(Markers.ENTRY, "");
+ } finally {
+ clearAuditFromMdc();
+ }
+ }
+
+
+ @Override
+ public void auditExit(AuditData data) {
+
+ if (data == null) {
+ return; // not failing if null
+ }
+
+ try {
+ putAuditOnMdc(data);
+ logger.info(Markers.EXIT, "");
} finally {
clearAuditFromMdc();
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java
index 7be90264d6..d2e75b1ac1 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/RoutingTest.java
@@ -113,7 +113,7 @@ public class RoutingTest {
@Test
public void testAudit() {
String msg = "This is a test audit";
- logger.info(Markers.AUDIT, msg);
+ logger.info(Markers.EXIT, msg);
TestAppender appender = result.get(AUDIT);
Assert.assertTrue(appender.contains(
(event) -> Level.INFO.equals(event.getLevel()) && msg.equals(event.getFormattedMessage())));
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java
index 2a71f72063..2001e16264 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/logback/EventTypeDiscriminatorTest.java
@@ -79,7 +79,7 @@ public class EventTypeDiscriminatorTest {
EventTypeDiscriminator discriminator = new EventTypeDiscriminator();
LoggingEvent event = new LoggingEvent();
event.setLevel(Level.ERROR);
- event.setMarker(Markers.AUDIT);
+ event.setMarker(Markers.EXIT);
assertEquals(ERROR, discriminator.getDiscriminatingValue(event));
}
@@ -97,7 +97,7 @@ public class EventTypeDiscriminatorTest {
EventTypeDiscriminator discriminator = new EventTypeDiscriminator();
LoggingEvent event = new LoggingEvent();
event.setLevel(Level.WARN);
- event.setMarker(Markers.AUDIT);
+ event.setMarker(Markers.EXIT);
assertEquals(ERROR, discriminator.getDiscriminatingValue(event));
}
@@ -115,7 +115,7 @@ public class EventTypeDiscriminatorTest {
EventTypeDiscriminator discriminator = new EventTypeDiscriminator();
LoggingEvent event = new LoggingEvent();
event.setLevel(Level.DEBUG);
- event.setMarker(Markers.AUDIT);
+ event.setMarker(Markers.EXIT);
assertEquals(DEBUG, discriminator.getDiscriminatingValue(event));
}
@@ -133,7 +133,7 @@ public class EventTypeDiscriminatorTest {
EventTypeDiscriminator discriminator = new EventTypeDiscriminator();
LoggingEvent event = new LoggingEvent();
event.setLevel(Level.TRACE);
- event.setMarker(Markers.AUDIT);
+ event.setMarker(Markers.EXIT);
assertEquals(DEBUG, discriminator.getDiscriminatingValue(event));
}
@@ -196,7 +196,7 @@ public class EventTypeDiscriminatorTest {
EventTypeDiscriminator discriminator = new EventTypeDiscriminator();
LoggingEvent event = new LoggingEvent();
event.setLevel(Level.INFO);
- event.setMarker(Markers.AUDIT);
+ event.setMarker(Markers.EXIT);
assertEquals("Audit", discriminator.getDiscriminatingValue(event));
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java
index 1e7cfe834f..9ecd5567e0 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/LoggingContextTest.java
@@ -147,7 +147,7 @@ public class LoggingContextTest {
String random = UUID.randomUUID().toString();
ContextData context = ContextData.builder().serviceName(random).build();
LoggingContext.put(context);
- assertEquals(context, LoggingContext.get());
+ assertEquals(context.getServiceName(), LoggingContext.get().getServiceName());
}
@Test
@@ -156,7 +156,7 @@ public class LoggingContextTest {
String random = UUID.randomUUID().toString();
ContextData context = ContextData.builder().requestId(random).build();
LoggingContext.put(context);
- assertEquals(context, LoggingContext.get());
+ assertEquals(context.getRequestId(), LoggingContext.get().getRequestId());
}
@Test
@@ -165,7 +165,7 @@ public class LoggingContextTest {
String random = UUID.randomUUID().toString();
ContextData context = ContextData.builder().partnerName(random).build();
LoggingContext.put(context);
- assertEquals(context, LoggingContext.get());
+ assertEquals(context.getPartnerName(), LoggingContext.get().getPartnerName());
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java
index c4c1677637..e0f8e40e4b 100644
--- a/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java
+++ b/openecomp-be/lib/openecomp-sdc-logging-lib/openecomp-sdc-logging-core/src/test/java/org/openecomp/sdc/logging/slf4j/RequestContextProviderTest.java
@@ -16,16 +16,14 @@
package org.openecomp.sdc.logging.slf4j;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import org.junit.Test;
import org.openecomp.sdc.logging.api.ContextData;
+import static org.junit.Assert.*;
+
/**
* Unit-test retrieving values from client-provided request data.
*
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 c8ee347a8b..2b98fc898f 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
@@ -19,6 +19,7 @@ package org.openecomp.sdc.logging.slf4j;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -28,7 +29,6 @@ import java.util.Map;
import org.junit.Test;
import org.openecomp.sdc.logging.api.AuditData;
import org.openecomp.sdc.logging.api.MetricsData;
-import org.openecomp.sdc.logging.api.StatusCode;
import org.slf4j.Logger;
import org.slf4j.MDC;
import org.slf4j.Marker;
@@ -44,7 +44,7 @@ public class SLF4JLoggerWrapperTest {
@Test
public void auditDoesNotFailWhenInputNull() {
- new SLF4JLoggerWrapper(this.getClass()).audit(null);
+ new SLF4JLoggerWrapper(this.getClass()).auditExit(null);
}
@Test
@@ -56,7 +56,7 @@ public class SLF4JLoggerWrapperTest {
public void auditBeginTimeAvailableWhenPassed() {
SpyLogger spy = createSpy();
long start = System.currentTimeMillis();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().startTime(start).build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().startTime(start).build());
assertNotNull(spy.mdc().get(AuditField.BEGIN_TIMESTAMP.asKey()));
}
@@ -72,7 +72,7 @@ public class SLF4JLoggerWrapperTest {
public void auditEndTimeAvailableWhenPassed() {
SpyLogger spy = createSpy();
long end = System.currentTimeMillis();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().endTime(end).build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().endTime(end).build());
assertNotNull(spy.mdc().get(AuditField.END_TIMESTAMP.asKey()));
}
@@ -88,7 +88,7 @@ public class SLF4JLoggerWrapperTest {
public void auditElapsedTimeAvailableWhenPassed() {
SpyLogger spy = createSpy();
long start = System.currentTimeMillis();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder()
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder()
.startTime(start).endTime(start + 777).build());
assertEquals("777", spy.mdc().get(AuditField.ELAPSED_TIME.asKey()));
}
@@ -105,21 +105,21 @@ public class SLF4JLoggerWrapperTest {
@Test
public void auditStatusCodeAvailableWhenPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().statusCode(StatusCode.COMPLETE).build());
- assertEquals(StatusCode.COMPLETE.name(), spy.mdc().get(AuditField.STATUS_CODE.asKey()));
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().statusCode(COMPLETE).build());
+ assertEquals(COMPLETE.name(), spy.mdc().get(AuditField.STATUS_CODE.asKey()));
}
@Test
public void metricsStatusCodeAvailableWhenPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).metrics(MetricsData.builder().statusCode(StatusCode.COMPLETE).build());
- assertEquals(StatusCode.COMPLETE.name(), spy.mdc().get(MetricsField.STATUS_CODE.asKey()));
+ new SLF4JLoggerWrapper(spy).metrics(MetricsData.builder().statusCode(COMPLETE).build());
+ assertEquals(COMPLETE.name(), spy.mdc().get(MetricsField.STATUS_CODE.asKey()));
}
@Test
public void auditStatusCodeEmptyWhenNotPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build());
assertNull(spy.mdc().get(AuditField.STATUS_CODE.asKey()));
}
@@ -134,7 +134,7 @@ public class SLF4JLoggerWrapperTest {
public void auditResponseCodeAvailableWhenPassed() {
final String responseCode = "AuditSpyResponse";
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().responseCode(responseCode).build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().responseCode(responseCode).build());
assertEquals(responseCode, spy.mdc().get(AuditField.RESPONSE_CODE.asKey()));
}
@@ -149,7 +149,7 @@ public class SLF4JLoggerWrapperTest {
@Test
public void auditResponseCodeEmptyWhenNotPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build());
assertNull(spy.mdc().get(AuditField.RESPONSE_CODE.asKey()));
}
@@ -164,7 +164,7 @@ public class SLF4JLoggerWrapperTest {
public void auditResponseDescriptionAvailableWhenPassed() {
final String responseDescription = "AuditSpyDescription";
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().responseDescription(responseDescription).build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().responseDescription(responseDescription).build());
assertEquals(responseDescription, spy.mdc().get(AuditField.RESPONSE_DESCRIPTION.asKey()));
}
@@ -179,7 +179,7 @@ public class SLF4JLoggerWrapperTest {
@Test
public void auditResponseDescriptionEmptyWhenNotPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build());
assertNull(spy.mdc().get(AuditField.RESPONSE_DESCRIPTION.asKey()));
}
@@ -194,7 +194,7 @@ public class SLF4JLoggerWrapperTest {
public void auditClientIpAddressAvailableWhenPassed() {
final String ipAddress = "10.56.20.20";
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().clientIpAddress(ipAddress).build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().clientIpAddress(ipAddress).build());
assertEquals(ipAddress, spy.mdc().get(AuditField.CLIENT_IP_ADDRESS.asKey()));
}
@@ -209,7 +209,7 @@ public class SLF4JLoggerWrapperTest {
@Test
public void auditClientIpAddressEmptyWhenNotPassed() {
SpyLogger spy = createSpy();
- new SLF4JLoggerWrapper(spy).audit(AuditData.builder().build());
+ new SLF4JLoggerWrapper(spy).auditExit(AuditData.builder().build());
assertNull(spy.mdc().get(AuditField.CLIENT_IP_ADDRESS.asKey()));
}
@@ -294,7 +294,7 @@ public class SLF4JLoggerWrapperTest {
}
private boolean isAuditMethod(Method method, Object[] args) {
- return isSpecialLogMethod(method, args, Markers.AUDIT);
+ return isSpecialLogMethod(method, args, Markers.EXIT);
}
private boolean isSpecialLogMethod(Method method, Object[] args, Marker marker) {