summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapLogConfiguration.java31
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapLoggerAudit.java43
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapLoggerBase.java5
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapLoggerError.java2
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapLoggerMetric.java51
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/OnapMDCWrapper.java47
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/Stopwatch.java15
-rw-r--r--src/main/java/org/onap/sdc/common/onaplog/interfaces/IOnapLogConfiguration.java31
8 files changed, 110 insertions, 115 deletions
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapLogConfiguration.java b/src/main/java/org/onap/sdc/common/onaplog/OnapLogConfiguration.java
new file mode 100644
index 0000000..bd34a5a
--- /dev/null
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapLogConfiguration.java
@@ -0,0 +1,31 @@
+package org.onap.sdc.common.onaplog;
+
+public class OnapLogConfiguration {
+ public static String MDC_KEY_REQUEST_ID = "RequestId";
+ public static String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceId";
+ public static String MDC_SERVICE_NAME = "ServiceName";
+ public static String MDC_INSTANCE_UUID = "InstanceUUID";
+ public static String MDC_SERVER_IP_ADDRESS = "ServerIPAddress";
+ public static String MDC_SERVER_FQDN = "ServerFQDN";
+ public static String MDC_REMOTE_HOST = "RemoteHost";
+ public static String MDC_ALERT_SEVERITY = "AlertSeverity";
+ public static String MDC_BEGIN_TIMESTAMP = "BeginTimestamp";
+ public static String MDC_END_TIMESTAMP = "EndTimestamp";
+ public static String MDC_PARTNER_NAME = "PartnerName";
+ public static String MDC_STATUS_CODE = "StatusCode";
+ public static String MDC_RESPONSE_CODE = "ResponseCode";
+ public static String MDC_RESPONSE_DESC = "ResponseDescription";
+ public static String MDC_ELAPSED_TIME = "ElapsedTime";
+ public static String MDC_PROCESS_KEY = "ProcessKey";
+ public static String MDC_TARGET_ENTITY = "TargetEntity";
+ public static String MDC_TARGET_SERVICE_NAME = "TargetServiceName";
+ public static String MDC_TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
+ public static String MDC_ERROR_CATEGORY = "ErrorCategory";
+ public static String MDC_ERROR_CODE = "ErrorCode";
+ public static String MDC_ERROR_DESC = "ErrorDescription";
+ public static String MDC_CLASS_NAME = "ClassName";
+ public static String MDC_OPT_FIELD1 = "CustomField1";
+ public static String MDC_OPT_FIELD2 = "CustomField2";
+ public static String MDC_OPT_FIELD3 = "CustomField3";
+ public static String MDC_OPT_FIELD4 = "CustomField4";
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerAudit.java b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerAudit.java
index 787b377..fc89ad4 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerAudit.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerAudit.java
@@ -4,7 +4,6 @@ import org.onap.sdc.common.onaplog.Enums.LogMarkers;
import org.onap.sdc.common.onaplog.Enums.OnapLoggerErrorCode;
import org.onap.sdc.common.onaplog.Enums.Severity;
import org.onap.sdc.common.onaplog.Enums.StatusCode;
-import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration;
import org.onap.sdc.common.onaplog.interfaces.IOnapMdcWrapper;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -140,28 +139,28 @@ public class OnapLoggerAudit extends OnapLoggerBase {
@Override
public void initializeMandatoryFields() {
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_END_TIMESTAMP);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_KEY_REQUEST_ID);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVICE_NAME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_PARTNER_NAME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_STATUS_CODE);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_RESPONSE_CODE);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_RESPONSE_DESC);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_ELAPSED_TIME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_END_TIMESTAMP);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_KEY_REQUEST_ID);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVICE_NAME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_PARTNER_NAME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_STATUS_CODE);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_RESPONSE_CODE);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_RESPONSE_DESC);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_ELAPSED_TIME);
//Theoretically Optional, but practically Mandatory
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVER_FQDN);
-
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_INSTANCE_UUID);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_ALERT_SEVERITY);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_REMOTE_HOST);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_CLASS_NAME);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_PROCESS_KEY);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD1);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD2);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD3);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD4);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVER_FQDN);
+
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_INSTANCE_UUID);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_ALERT_SEVERITY);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_REMOTE_HOST);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_CLASS_NAME);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_PROCESS_KEY);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD1);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD2);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD3);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD4);
}
}
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerBase.java b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerBase.java
index 5e8f841..ca79843 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerBase.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerBase.java
@@ -1,7 +1,6 @@
package org.onap.sdc.common.onaplog;
import org.onap.sdc.common.onaplog.Enums.LogLevel;
-import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration;
import org.onap.sdc.common.onaplog.interfaces.IOnapLogger;
import org.onap.sdc.common.onaplog.interfaces.IOnapMdcWrapper;
import org.slf4j.Logger;
@@ -33,8 +32,8 @@ public abstract class OnapLoggerBase implements IOnapLogger {
public void log(LogLevel errorLevel, String className, String message, Object... args) {
MDC.put("ClassName", className);
if (this instanceof OnapLoggerAudit || this instanceof OnapLoggerMetric) {
- MDC.put(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS, OnapMDCWrapper.getInstance().getHostAddress());
- MDC.put(IOnapLogConfiguration.MDC_SERVER_FQDN, OnapMDCWrapper.getInstance().getFqdn());
+ MDC.put(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS, OnapMDCWrapper.getInstance().getHostAddress());
+ MDC.put(OnapLogConfiguration.MDC_SERVER_FQDN, OnapMDCWrapper.getInstance().getFqdn());
}
onapMDCWrapper.validateMandatoryFields();
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerError.java b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerError.java
index 44f8467..9734419 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerError.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerError.java
@@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
import org.slf4j.MDC;
-import static org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration.*;
+import static org.onap.sdc.common.onaplog.OnapLogConfiguration.*;
public class OnapLoggerError extends OnapLoggerBase {
private static OnapLoggerError instanceLoggerError = OnapLoggerFactory.getLogger(OnapLoggerError.class);
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerMetric.java b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerMetric.java
index 9c77bf3..5b9dd08 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerMetric.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapLoggerMetric.java
@@ -2,7 +2,6 @@ package org.onap.sdc.common.onaplog;
import org.onap.sdc.common.onaplog.Enums.LogMarkers;
import org.onap.sdc.common.onaplog.Enums.Severity;
-import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration;
import org.onap.sdc.common.onaplog.interfaces.IOnapMdcWrapper;
import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
@@ -152,33 +151,33 @@ public class OnapLoggerMetric extends OnapLoggerBase {
@Override
public void initializeMandatoryFields() {
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_END_TIMESTAMP);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_KEY_REQUEST_ID);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVICE_NAME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_PARTNER_NAME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_STATUS_CODE);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_RESPONSE_CODE);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVICE_INSTANCE_ID);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_RESPONSE_DESC);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_ELAPSED_TIME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_TARGET_ENTITY);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_TARGET_SERVICE_NAME);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_END_TIMESTAMP);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_KEY_REQUEST_ID);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVICE_NAME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_PARTNER_NAME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_STATUS_CODE);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_RESPONSE_CODE);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVICE_INSTANCE_ID);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_RESPONSE_DESC);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_ELAPSED_TIME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_TARGET_ENTITY);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_TARGET_SERVICE_NAME);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY);
//Theoretically Optional, but practically Mandatory
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS);
- onapMDCWrapper.setMandatoryField(IOnapLogConfiguration.MDC_SERVER_FQDN);
-
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_INSTANCE_UUID);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_ALERT_SEVERITY);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_REMOTE_HOST);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_CLASS_NAME);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_PROCESS_KEY);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD1);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD2);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD3);
- onapMDCWrapper.setOptionalField(IOnapLogConfiguration.MDC_OPT_FIELD4);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS);
+ onapMDCWrapper.setMandatoryField(OnapLogConfiguration.MDC_SERVER_FQDN);
+
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_INSTANCE_UUID);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_ALERT_SEVERITY);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_REMOTE_HOST);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_CLASS_NAME);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_PROCESS_KEY);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD1);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD2);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD3);
+ onapMDCWrapper.setOptionalField(OnapLogConfiguration.MDC_OPT_FIELD4);
}
diff --git a/src/main/java/org/onap/sdc/common/onaplog/OnapMDCWrapper.java b/src/main/java/org/onap/sdc/common/onaplog/OnapMDCWrapper.java
index d992a8b..2249f14 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/OnapMDCWrapper.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/OnapMDCWrapper.java
@@ -1,7 +1,6 @@
package org.onap.sdc.common.onaplog;
import org.onap.sdc.common.onaplog.Enums.Severity;
-import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration;
import org.onap.sdc.common.onaplog.interfaces.IOnapMdcWrapper;
import org.onap.sdc.common.onaplog.interfaces.IStopWatch;
import org.slf4j.Logger;
@@ -60,141 +59,141 @@ public class OnapMDCWrapper implements IOnapMdcWrapper {
@Override
public OnapMDCWrapper setClassName(String className) {
- MDC.put(IOnapLogConfiguration.MDC_CLASS_NAME, className);
+ MDC.put(OnapLogConfiguration.MDC_CLASS_NAME, className);
return this;
}
// automatic parameter this is optional
@Override
public OnapMDCWrapper setAutoServerFQDN(String serverFQDN) {
- MDC.put(IOnapLogConfiguration.MDC_SERVER_FQDN, serverFQDN);
+ MDC.put(OnapLogConfiguration.MDC_SERVER_FQDN, serverFQDN);
return this;
}
// automatic parameter this is optional
@Override
public OnapMDCWrapper setAutoServerIPAddress(String serverIPAddress) {
- MDC.put(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS, serverIPAddress);
+ MDC.put(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS, serverIPAddress);
return this;
}
@Override
public OnapMDCWrapper setInstanceUUID(String instanceUUID) {
- MDC.put(IOnapLogConfiguration.MDC_INSTANCE_UUID, instanceUUID);
+ MDC.put(OnapLogConfiguration.MDC_INSTANCE_UUID, instanceUUID);
return this;
}
@Override
public OnapMDCWrapper setProcessKey(String processKey) {
- MDC.put(IOnapLogConfiguration.MDC_PROCESS_KEY, processKey);
+ MDC.put(OnapLogConfiguration.MDC_PROCESS_KEY, processKey);
return this;
}
@Override
public OnapMDCWrapper setAlertSeverity(Severity alertSeverity) {
- MDC.put(IOnapLogConfiguration.MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType()));
+ MDC.put(OnapLogConfiguration.MDC_ALERT_SEVERITY, String.valueOf(alertSeverity.getSeverityType()));
return this;
}
@Override
public OnapMDCWrapper setOptCustomField1(String customField1) {
- MDC.put(IOnapLogConfiguration.MDC_OPT_FIELD1, customField1);
+ MDC.put(OnapLogConfiguration.MDC_OPT_FIELD1, customField1);
return this;
}
@Override
public OnapMDCWrapper setOptCustomField2(String customField2) {
- MDC.put(IOnapLogConfiguration.MDC_OPT_FIELD2, customField2);
+ MDC.put(OnapLogConfiguration.MDC_OPT_FIELD2, customField2);
return this;
}
@Override
public OnapMDCWrapper setOptCustomField3(String customField3) {
- MDC.put(IOnapLogConfiguration.MDC_OPT_FIELD3, customField3);
+ MDC.put(OnapLogConfiguration.MDC_OPT_FIELD3, customField3);
return this;
}
@Override
public OnapMDCWrapper setOptCustomField4(String customField4) {
- MDC.put(IOnapLogConfiguration.MDC_OPT_FIELD4, customField4);
+ MDC.put(OnapLogConfiguration.MDC_OPT_FIELD4, customField4);
return this;
}
@Override
public OnapMDCWrapper setKeyRequestId(String keyRequestId) {
- MDC.put(IOnapLogConfiguration.MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId()
+ MDC.put(OnapLogConfiguration.MDC_KEY_REQUEST_ID, keyRequestId); // eg. servletRequest.getSession().getId()
return this;
}
@Override
public OnapMDCWrapper setRemoteHost(String remoteHost) {
- MDC.put(IOnapLogConfiguration.MDC_REMOTE_HOST, remoteHost);
+ MDC.put(OnapLogConfiguration.MDC_REMOTE_HOST, remoteHost);
return this;
}
@Override
public OnapMDCWrapper setServiceName(String serviceName) {
- MDC.put(IOnapLogConfiguration.MDC_SERVICE_NAME, serviceName);
+ MDC.put(OnapLogConfiguration.MDC_SERVICE_NAME, serviceName);
return this;
}
@Override
public OnapMDCWrapper setStatusCode(String statusCode) {
- MDC.put(IOnapLogConfiguration.MDC_STATUS_CODE, statusCode);
+ MDC.put(OnapLogConfiguration.MDC_STATUS_CODE, statusCode);
return this;
}
@Override
public OnapMDCWrapper setPartnerName(String partnerName) {
- MDC.put(IOnapLogConfiguration.MDC_PARTNER_NAME, partnerName);
+ MDC.put(OnapLogConfiguration.MDC_PARTNER_NAME, partnerName);
return this;
}
@Override
public OnapMDCWrapper setResponseCode(int responseCode) {
- MDC.put(IOnapLogConfiguration.MDC_RESPONSE_CODE, Integer.toString(responseCode));
+ MDC.put(OnapLogConfiguration.MDC_RESPONSE_CODE, Integer.toString(responseCode));
return this;
}
@Override
public OnapMDCWrapper setResponseDesc(String responseDesc) {
- MDC.put(IOnapLogConfiguration.MDC_RESPONSE_DESC, responseDesc);
+ MDC.put(OnapLogConfiguration.MDC_RESPONSE_DESC, responseDesc);
return this;
}
@Override
public OnapMDCWrapper setServiceInstanceId(String serviceInstanceId) {
- MDC.put(IOnapLogConfiguration.MDC_SERVICE_INSTANCE_ID, serviceInstanceId);
+ MDC.put(OnapLogConfiguration.MDC_SERVICE_INSTANCE_ID, serviceInstanceId);
return this;
}
@Override
public OnapMDCWrapper setTargetEntity(String targetEntity) {
- MDC.put(IOnapLogConfiguration.MDC_TARGET_ENTITY, targetEntity);
+ MDC.put(OnapLogConfiguration.MDC_TARGET_ENTITY, targetEntity);
return this;
}
@Override
public OnapMDCWrapper setTargetServiceName(String targetServiceName) {
- MDC.put(IOnapLogConfiguration.MDC_TARGET_SERVICE_NAME, targetServiceName);
+ MDC.put(OnapLogConfiguration.MDC_TARGET_SERVICE_NAME, targetServiceName);
return this;
}
@Override
public OnapMDCWrapper setTargetVirtualEntity(String targetVirtualEntity) {
- MDC.put(IOnapLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity);
+ MDC.put(OnapLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity);
return this;
}
@Override
public OnapMDCWrapper setErrorCode(int errorCode) {
- MDC.put(IOnapLogConfiguration.MDC_ERROR_CODE, Integer.toString(errorCode));
+ MDC.put(OnapLogConfiguration.MDC_ERROR_CODE, Integer.toString(errorCode));
return this;
}
@Override
public OnapMDCWrapper setErrorDescription(String errorDescription) {
- MDC.put(IOnapLogConfiguration.MDC_ERROR_DESC, errorDescription);
+ MDC.put(OnapLogConfiguration.MDC_ERROR_DESC, errorDescription);
return this;
}
diff --git a/src/main/java/org/onap/sdc/common/onaplog/Stopwatch.java b/src/main/java/org/onap/sdc/common/onaplog/Stopwatch.java
index 20582b9..3c6c0da 100644
--- a/src/main/java/org/onap/sdc/common/onaplog/Stopwatch.java
+++ b/src/main/java/org/onap/sdc/common/onaplog/Stopwatch.java
@@ -1,6 +1,5 @@
package org.onap.sdc.common.onaplog;
-import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration;
import org.onap.sdc.common.onaplog.interfaces.IStopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,16 +22,16 @@ public class Stopwatch implements IStopWatch {
}
public void start() {
- if (MDC.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP) == null || MDC.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP).trim().length() == 0) {
- MDC.put(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP, generatedTimeNow());
+ if (MDC.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP) == null || MDC.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP).trim().length() == 0) {
+ MDC.put(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP, generatedTimeNow());
}
}
public void stop() {
- if (MDC.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP) == null) {
+ if (MDC.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP) == null) {
log.error("call to stop without calling start first, this is not compliant with EELF format");
}
- MDC.put(IOnapLogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow());
+ MDC.put(OnapLogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow());
setElapsedTime();
}
@@ -40,12 +39,12 @@ public class Stopwatch implements IStopWatch {
try {
- final LocalDateTime startTime = LocalDateTime.parse(MDC.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP));
- final LocalDateTime endTime = LocalDateTime.parse(MDC.get(IOnapLogConfiguration.MDC_END_TIMESTAMP));
+ final LocalDateTime startTime = LocalDateTime.parse(MDC.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP));
+ final LocalDateTime endTime = LocalDateTime.parse(MDC.get(OnapLogConfiguration.MDC_END_TIMESTAMP));
final Duration timeDifference = Duration.between(startTime, endTime);
- MDC.put(IOnapLogConfiguration.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis()));
+ MDC.put(OnapLogConfiguration.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis()));
} catch(Exception ex) {
log.error("failed to calculate elapsed time",ex);
diff --git a/src/main/java/org/onap/sdc/common/onaplog/interfaces/IOnapLogConfiguration.java b/src/main/java/org/onap/sdc/common/onaplog/interfaces/IOnapLogConfiguration.java
deleted file mode 100644
index 55c4b00..0000000
--- a/src/main/java/org/onap/sdc/common/onaplog/interfaces/IOnapLogConfiguration.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.onap.sdc.common.onaplog.interfaces;
-
-public interface IOnapLogConfiguration {
- String MDC_KEY_REQUEST_ID = "RequestId";
- String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceId";
- String MDC_SERVICE_NAME = "ServiceName";
- String MDC_INSTANCE_UUID = "InstanceUUID";
- String MDC_SERVER_IP_ADDRESS = "ServerIPAddress";
- String MDC_SERVER_FQDN = "ServerFQDN";
- String MDC_REMOTE_HOST = "RemoteHost";
- String MDC_ALERT_SEVERITY = "AlertSeverity";
- String MDC_BEGIN_TIMESTAMP = "BeginTimestamp";
- String MDC_END_TIMESTAMP = "EndTimestamp";
- String MDC_PARTNER_NAME = "PartnerName";
- String MDC_STATUS_CODE = "StatusCode";
- String MDC_RESPONSE_CODE = "ResponseCode";
- String MDC_RESPONSE_DESC = "ResponseDescription";
- String MDC_ELAPSED_TIME = "ElapsedTime";
- String MDC_PROCESS_KEY = "ProcessKey";
- String MDC_TARGET_ENTITY = "TargetEntity";
- String MDC_TARGET_SERVICE_NAME = "TargetServiceName";
- String MDC_TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
- String MDC_ERROR_CATEGORY = "ErrorCategory";
- String MDC_ERROR_CODE = "ErrorCode";
- String MDC_ERROR_DESC = "ErrorDescription";
- String MDC_CLASS_NAME = "ClassName";
- String MDC_OPT_FIELD1 = "CustomField1";
- String MDC_OPT_FIELD2 = "CustomField2";
- String MDC_OPT_FIELD3 = "CustomField3";
- String MDC_OPT_FIELD4 = "CustomField4";
-} \ No newline at end of file