diff options
Diffstat (limited to 'common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java')
-rw-r--r-- | common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java | 116 |
1 files changed, 78 insertions, 38 deletions
diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java index 8af85ea1a3..c23861f1ff 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerMetric.java @@ -1,5 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2020, Nordix Foundation. 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.openecomp.sdc.common.log.elements; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.INSTANCE_UUID; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.INVOKE_TIMESTAMP; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.PARTNER_NAME; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.REQUEST_ID; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_CODE; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_SEVERITY; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVER_FQDN; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVICE_NAME; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.TARGET_ENTITY; +import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.TARGET_SERVICE_NAME; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_CLASS_NAME; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_ELAPSED_TIME; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_END_TIMESTAMP; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD1; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD2; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD3; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD4; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_PROCESS_KEY; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_REMOTE_HOST; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVER_IP_ADDRESS; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_SERVICE_INSTANCE_ID; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.ws.rs.core.Response; import org.openecomp.sdc.common.log.api.ILogFieldsHandler; import org.openecomp.sdc.common.log.enums.LogLevel; import org.openecomp.sdc.common.log.enums.LogMarkers; @@ -7,48 +56,41 @@ import org.openecomp.sdc.common.log.enums.Severity; import org.slf4j.Logger; import org.slf4j.MarkerFactory; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.*; -import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; - public class LoggerMetric extends LoggerBase { + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( - INVOKE_TIMESTAMP, - MDC_END_TIMESTAMP, - REQUEST_ID, - SERVICE_NAME, - PARTNER_NAME, - RESPONSE_CODE, - MDC_SERVICE_INSTANCE_ID, - RESPONSE_DESCRIPTION, - MDC_ELAPSED_TIME, - TARGET_ENTITY, - MDC_SERVER_IP_ADDRESS, - SERVER_FQDN)); + INVOKE_TIMESTAMP, + MDC_END_TIMESTAMP, + REQUEST_ID, + SERVICE_NAME, + PARTNER_NAME, + RESPONSE_CODE, + MDC_SERVICE_INSTANCE_ID, + RESPONSE_DESCRIPTION, + MDC_ELAPSED_TIME, + TARGET_ENTITY, + MDC_SERVER_IP_ADDRESS, + SERVER_FQDN)); private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( - MDC_TARGET_VIRTUAL_ENTITY, - TARGET_ENTITY, - TARGET_SERVICE_NAME, - RESPONSE_STATUS_CODE, - INSTANCE_UUID, - RESPONSE_SEVERITY, - MDC_REMOTE_HOST, - CLIENT_IP_ADDRESS, - MDC_CLASS_NAME, - MDC_PROCESS_KEY, - MDC_OPT_FIELD1, - MDC_OPT_FIELD2, - MDC_OPT_FIELD3, - MDC_OPT_FIELD4)); + MDC_TARGET_VIRTUAL_ENTITY, + TARGET_ENTITY, + TARGET_SERVICE_NAME, + RESPONSE_STATUS_CODE, + INSTANCE_UUID, + RESPONSE_SEVERITY, + MDC_REMOTE_HOST, + CLIENT_IP_ADDRESS, + MDC_CLASS_NAME, + MDC_PROCESS_KEY, + MDC_OPT_FIELD1, + MDC_OPT_FIELD2, + MDC_OPT_FIELD3, + MDC_OPT_FIELD4)); LoggerMetric(ILogFieldsHandler ecompMdcWrapper, Logger logger) { - super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.text()), logger); + super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.METRIC_MARKER.getText()), logger); //put the remote host and FQDN values from another thread if they are set ecompMdcWrapper.setServerIPAddressInternally(); ecompMdcWrapper.setServerFQDNInternally(); @@ -59,7 +101,7 @@ public class LoggerMetric extends LoggerBase { LogLevel logLevel, Severity securityLevel, String message) { - log(statusInfo,className, logLevel, securityLevel, message); + log(statusInfo, className, logLevel, securityLevel, message); } @Override @@ -168,6 +210,4 @@ public class LoggerMetric extends LoggerBase { } - - } |