summaryrefslogtreecommitdiffstats
path: root/policy-utils/src/main/java/org/onap
diff options
context:
space:
mode:
authorJoseph Chou <jc2555@att.com>2020-05-20 13:32:30 -0400
committerJorge Hernandez <jorge.hernandez-herrero@att.com>2020-06-05 12:44:07 +0000
commit67644ebb81b6b3c8cb2b3fd90bd338ce881ff453 (patch)
tree9acd2f255950e7428be34982ac1edcfdf9b1e96c /policy-utils/src/main/java/org/onap
parent4ce931cf48b253b057896774570e0eba814fd306 (diff)
Change metrics and transactions layout in logback.xml
Update logging code to compliant with logging standard Issue-ID: POLICY-2578 Change-Id: I98decce81eae95c006d6485bf3440ac9119b2bf5 Signed-off-by: Joseph Chou <jc2555@att.com>
Diffstat (limited to 'policy-utils/src/main/java/org/onap')
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java42
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java23
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java69
3 files changed, 128 insertions, 6 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
index a2cf07fb..94fc9769 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransaction.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -197,6 +197,26 @@ public interface MdcTransaction {
MdcTransaction setRemoteHost(String remoteHost);
/**
+ * sets CustomField1 data.
+ */
+ MdcTransaction setCustomField1(String customField1);
+
+ /**
+ * sets CustomField2 data.
+ */
+ MdcTransaction setCustomField2(String customField2);
+
+ /**
+ * sets CustomField3 data.
+ */
+ MdcTransaction setCustomField3(String customField3);
+
+ /**
+ * sets CustomField4 data.
+ */
+ MdcTransaction setCustomField4(String customField4);
+
+ /**
* get start time.
*/
Instant getStartTime();
@@ -312,6 +332,26 @@ public interface MdcTransaction {
String getServerIpAddress();
/**
+ * get customer field1.
+ */
+ String getCustomField1();
+
+ /**
+ * get customer field2.
+ */
+ String getCustomField2();
+
+ /**
+ * get customer field3 which contains notification info.
+ */
+ String getCustomField3();
+
+ /**
+ * get customer field4.
+ */
+ String getCustomField4();
+
+ /**
* generate timestamp used for logging.
*/
String timestamp(Instant time);
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
index eb37d0c7..936449c8 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* policy-utils
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -144,6 +144,26 @@ public class MdcTransactionConstants {
public static final String TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity";
/**
+ * Custom Field1.
+ */
+ public static final String CUSTOM_FIELD1 = "CustomField1";
+
+ /**
+ * Custom Field2.
+ */
+ public static final String CUSTOM_FIELD2 = "CustomField2";
+
+ /**
+ * Custom Field3.
+ */
+ public static final String CUSTOM_FIELD3 = "CustomField3";
+
+ /**
+ * Custom Field4.
+ */
+ public static final String CUSTOM_FIELD4 = "CustomField4";
+
+ /**
* Default Service Name.
*/
public static final String DEFAULT_SERVICE_NAME = "PDP-D";
@@ -168,7 +188,6 @@ public class MdcTransactionConstants {
*/
public static final String STATUS_CODE_FAILURE = "ERROR";
-
private MdcTransactionConstants() {
// do nothing
}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
index 4e1690ba..7af6c0cb 100644
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
+++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionImpl.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,10 @@ package org.onap.policy.drools.utils.logging;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.BEGIN_TIMESTAMP;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CLIENT_IP_ADDRESS;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD1;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD2;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD3;
+import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.CUSTOM_FIELD4;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTIP;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_HOSTNAME;
import static org.onap.policy.drools.utils.logging.MdcTransactionConstants.DEFAULT_SERVICE_NAME;
@@ -100,6 +104,10 @@ class MdcTransactionImpl implements MdcTransaction {
private String targetVirtualEntity;
private String clientIpAddress;
private String remoteHost;
+ private String customField1;
+ private String customField2;
+ private String customField3;
+ private String customField4;
/**
* Transaction with no information set.
@@ -145,8 +153,8 @@ class MdcTransactionImpl implements MdcTransaction {
this.setServerFqdn(MDC.get(SERVER_FQDN));
this.setVirtualServerName(MDC.get(VIRTUAL_SERVER_NAME));
- this.setStartTime(Instant.now());
this.setInvocationId(invocationId);
+ this.setStartTime(Instant.now());
}
/**
@@ -179,6 +187,10 @@ class MdcTransactionImpl implements MdcTransaction {
this.setTargetServiceName(transaction.getTargetServiceName());
this.setTargetVirtualEntity(transaction.getTargetVirtualEntity());
this.setVirtualServerName(transaction.getVirtualServerName());
+ this.setCustomField1(transaction.getCustomField1());
+ this.setCustomField2(transaction.getCustomField2());
+ this.setCustomField3(transaction.getCustomField3());
+ this.setCustomField4(transaction.getCustomField4());
}
/**
@@ -248,6 +260,10 @@ class MdcTransactionImpl implements MdcTransaction {
setMdc(TARGET_VIRTUAL_ENTITY, this.targetVirtualEntity);
setMdc(CLIENT_IP_ADDRESS, this.clientIpAddress);
setMdc(REMOTE_HOST, this.remoteHost);
+ setMdc(CUSTOM_FIELD1, this.customField1);
+ setMdc(CUSTOM_FIELD2, this.customField2);
+ setMdc(CUSTOM_FIELD3, this.customField3);
+ setMdc(CUSTOM_FIELD4, this.customField4);
return this;
}
@@ -352,6 +368,26 @@ class MdcTransactionImpl implements MdcTransaction {
return this.serviceInstanceId;
}
+ @Override
+ public String getCustomField1() {
+ return this.customField1;
+ }
+
+ @Override
+ public String getCustomField2() {
+ return this.customField2;
+ }
+
+ @Override
+ public String getCustomField3() {
+ return this.customField3;
+ }
+
+ @Override
+ public String getCustomField4() {
+ return this.customField4;
+ }
+
/* transaction and subtransaction fields */
@Override
@@ -458,6 +494,30 @@ class MdcTransactionImpl implements MdcTransaction {
}
@Override
+ public MdcTransaction setCustomField1(String customField1) {
+ this.customField1 = customField1;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField2(String customField2) {
+ this.customField2 = customField2;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField3(String customField3) {
+ this.customField3 = customField3;
+ return this;
+ }
+
+ @Override
+ public MdcTransaction setCustomField4(String customField4) {
+ this.customField4 = customField4;
+ return this;
+ }
+
+ @Override
public String getInvocationId() {
return invocationId;
}
@@ -641,8 +701,11 @@ class MdcTransactionImpl implements MdcTransaction {
sb.append(", targetVirtualEntity='").append(targetVirtualEntity).append('\'');
sb.append(", clientIpAddress='").append(clientIpAddress).append('\'');
sb.append(", remoteHost='").append(remoteHost).append('\'');
+ sb.append(", customField1='").append(customField1).append('\'');
+ sb.append(", customField2='").append(customField2).append('\'');
+ sb.append(", customField3='").append(customField3).append('\'');
+ sb.append(", customField4='").append(customField4).append('\'');
sb.append('}');
return sb.toString();
}
-
}