summaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorPierre Rioux <pierre.rioux@amdocs.com>2019-10-18 20:08:40 +0000
committerGerrit Code Review <gerrit@onap.org>2019-10-18 20:08:40 +0000
commitef6bcef32ab4d363cf844ae91c954df4adb798eb (patch)
tree4b2be411053775289c62a1bc32e40a6d3318bc3b /reference
parent40d60912a2de47be35379c5fe786e1d2d0b180c8 (diff)
parent455999fe660897fefd8d4f84a47ab5caca6c247a (diff)
Merge "enhance AbstractMetricLogFilter"
Diffstat (limited to 'reference')
-rw-r--r--reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java10
-rw-r--r--reference/logging-filter/logging-filter-base/src/test/resources/log4j2.properties2
2 files changed, 12 insertions, 0 deletions
diff --git a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
index fc67460..79069c1 100644
--- a/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
+++ b/reference/logging-filter/logging-filter-base/src/main/java/org/onap/logging/filter/base/AbstractMetricLogFilter.java
@@ -56,12 +56,17 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders>
try {
setupMDC(request);
setupHeaders(request, requestHeaders);
+ additionalPre(request, requestHeaders);
logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
} catch (Exception e) {
logger.warn("Error in AbstractMetricLogFilter pre", e);
}
}
+ protected void additionalPre(Request request, RequestHeaders requestHeaders) {
+ // override to add application specific logic
+ }
+
protected void setupHeaders(Request clientRequest, RequestHeaders requestHeaders) {
String requestId = extractRequestID();
String invocationId = UUID.randomUUID().toString();
@@ -117,6 +122,7 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders>
setResponseStatusCode(getHttpStatusCode(response));
setResponseDescription(getHttpStatusCode(response));
MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, getResponseCode(response));
+ additionalPost(request, response);
logger.info(INVOKE_RETURN, "InvokeReturn");
clearClientMDCs();
} catch (Exception e) {
@@ -124,6 +130,10 @@ public abstract class AbstractMetricLogFilter<Request, Response, RequestHeaders>
}
}
+ protected void additionalPost(Request request, Response response) {
+ // override to add application specific logic
+ }
+
protected String getPartnerName() {
return getProperty(Constants.Property.PARTNER_NAME);
}
diff --git a/reference/logging-filter/logging-filter-base/src/test/resources/log4j2.properties b/reference/logging-filter/logging-filter-base/src/test/resources/log4j2.properties
index 856bb26..04446cd 100644
--- a/reference/logging-filter/logging-filter-base/src/test/resources/log4j2.properties
+++ b/reference/logging-filter/logging-filter-base/src/test/resources/log4j2.properties
@@ -1,6 +1,8 @@
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %X|%m%n
rootLogger.level = TRACE
rootLogger.appenderRefs = stdout