1 package org.openecomp.sdc.common.ecomplog;
3 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ALERT_SEVERITY;
4 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP;
5 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_CLASS_NAME;
6 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ELAPSED_TIME;
7 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_END_TIMESTAMP;
8 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_INSTANCE_UUID;
9 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID;
10 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD1;
11 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD2;
12 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD3;
13 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_OPT_FIELD4;
14 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME;
15 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PROCESS_KEY;
16 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_REMOTE_HOST;
17 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_CODE;
18 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_RESPONSE_DESC;
19 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_FQDN;
20 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVER_IP_ADDRESS;
21 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_INSTANCE_ID;
22 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME;
23 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_STATUS_CODE;
24 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY;
25 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME;
26 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_VIRTUAL_ENTITY;
28 import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers;
29 import org.openecomp.sdc.common.ecomplog.Enums.Severity;
30 import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper;
31 import org.slf4j.MarkerFactory;
34 public class EcompLoggerMetric extends EcompLoggerBase{
35 private static EcompLoggerMetric instanceLoggerMetric = (EcompLoggerMetric) EcompLoggerFactory.getLogger(EcompLoggerMetric.class);
37 EcompLoggerMetric(IEcompMdcWrapper ecompMdcWrapper) {
38 super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text()));
41 public static EcompLoggerMetric getInstance() {
42 return instanceLoggerMetric;
46 public EcompLoggerMetric startTimer() {
47 return (EcompLoggerMetric) super.startTimer();
51 public EcompLoggerMetric setKeyRequestId(String keyRequestId) {
52 return (EcompLoggerMetric) super.setKeyRequestId(keyRequestId);
55 public EcompLoggerMetric stopTimer() {
56 ecompMdcWrapper.stopTimer();
60 // automatic parameter this is optional
61 public EcompLoggerMetric setAutoServerFQDN(String serverFQDN) {
62 ecompMdcWrapper.setAutoServerFQDN(serverFQDN);
66 // automatic parameter this is optional
67 public EcompLoggerMetric setAutoServerIPAddress(String serverIPAddress) {
68 ecompMdcWrapper.setAutoServerIPAddress(serverIPAddress);
72 public EcompLoggerMetric setInstanceUUID(String instanceUUID) {
73 ecompMdcWrapper.setInstanceUUID(instanceUUID);
77 // ecomplog optional parameter
78 public EcompLoggerMetric setOptProcessKey(String processKey) {
79 ecompMdcWrapper.setProcessKey(processKey);
83 // ecomplog optional parameter
84 public EcompLoggerMetric setOptAlertSeverity(Severity alertSeverity) {
85 ecompMdcWrapper.setAlertSeverity(alertSeverity);
89 // ecomplog optional parameter
90 public EcompLoggerMetric setOptCustomField1(String customField1) {
91 ecompMdcWrapper.setOptCustomField1(customField1);
95 // ecomplog optional parameter
96 public EcompLoggerMetric setOptCustomField2(String customField2) {
97 ecompMdcWrapper.setOptCustomField2(customField2);
101 // ecomplog optional parameter
102 public EcompLoggerMetric setOptCustomField3(String customField3) {
103 ecompMdcWrapper.setOptCustomField3(customField3);
107 // ecomplog optional parameter
108 public EcompLoggerMetric setOptCustomField4(String customField4) {
109 ecompMdcWrapper.setOptCustomField4(customField4);
113 public EcompLoggerMetric setRemoteHost(String remoteHost) {
114 ecompMdcWrapper.setRemoteHost(remoteHost);
118 public EcompLoggerMetric setServiceName(String serviceName) {
119 ecompMdcWrapper.setServiceName(serviceName);
123 public EcompLoggerMetric setStatusCode(String statusCode) {
124 ecompMdcWrapper.setStatusCode(statusCode);
128 public EcompLoggerMetric setPartnerName(String partnerName) {
129 ecompMdcWrapper.setPartnerName(partnerName);
133 public EcompLoggerMetric setResponseCode(int responseCode) {
134 ecompMdcWrapper.setResponseCode(responseCode);
138 public EcompLoggerMetric setResponseDesc(String responseDesc) {
139 ecompMdcWrapper.setResponseDesc(responseDesc);
143 public EcompLoggerMetric setOptServiceInstanceId(String serviceInstanceId) {
144 ecompMdcWrapper.setServiceInstanceId(serviceInstanceId);
148 public EcompLoggerMetric setOptClassName(String className) {
149 ecompMdcWrapper.setClassName(className);
153 public EcompLoggerMetric setTargetEntity(String targetEntity) {
154 ecompMdcWrapper.setTargetEntity(targetEntity);
158 public EcompLoggerMetric setTargetServiceName(String targetServiceName) {
159 ecompMdcWrapper.setTargetServiceName(targetServiceName);
163 public EcompLoggerMetric setTargetVirtualEntity(String targetVirtualEntity) {
164 ecompMdcWrapper.setTargetVirtualEntity(targetVirtualEntity);
169 public EcompLoggerMetric clear () {
170 return (EcompLoggerMetric) super.clear();
175 public void initializeMandatoryFields() {
177 ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP);
178 ecompMdcWrapper.setMandatoryField(MDC_END_TIMESTAMP);
179 ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID);
180 ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME);
181 ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME);
182 ecompMdcWrapper.setMandatoryField(MDC_STATUS_CODE);
183 ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_CODE);
184 ecompMdcWrapper.setMandatoryField(MDC_SERVICE_INSTANCE_ID);
185 ecompMdcWrapper.setMandatoryField(MDC_RESPONSE_DESC);
186 ecompMdcWrapper.setMandatoryField(MDC_ELAPSED_TIME);
187 ecompMdcWrapper.setMandatoryField(MDC_TARGET_ENTITY);
188 ecompMdcWrapper.setMandatoryField(MDC_TARGET_SERVICE_NAME);
189 ecompMdcWrapper.setMandatoryField(MDC_TARGET_VIRTUAL_ENTITY);
191 //Theoretically Optional, but practically Mandatory
192 ecompMdcWrapper.setMandatoryField(MDC_SERVER_IP_ADDRESS);
193 ecompMdcWrapper.setMandatoryField(MDC_SERVER_FQDN);
195 ecompMdcWrapper.setOptionalField(MDC_INSTANCE_UUID);
196 ecompMdcWrapper.setOptionalField(MDC_ALERT_SEVERITY);
197 ecompMdcWrapper.setOptionalField(MDC_REMOTE_HOST);
198 ecompMdcWrapper.setOptionalField(MDC_CLASS_NAME);
199 ecompMdcWrapper.setOptionalField(MDC_PROCESS_KEY);
200 ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD1);
201 ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD2);
202 ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD3);
203 ecompMdcWrapper.setOptionalField(MDC_OPT_FIELD4);