diff options
Diffstat (limited to 'common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements')
9 files changed, 125 insertions, 274 deletions
diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/ErrorLogOptionalData.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/ErrorLogOptionalData.java index d5279b1101..fce1143ad1 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/ErrorLogOptionalData.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/ErrorLogOptionalData.java @@ -1,37 +1,28 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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; public class ErrorLogOptionalData { private String targetEntity; private String targetServiceName; + public ErrorLogOptionalData() { + } + String getTargetEntity() { return targetEntity; } + private void setTargetEntity(String targetEntity) { + this.targetEntity = targetEntity; + } + String getTargetServiceName() { return targetServiceName; } + private void setTargetServiceName(String targetServiceName) { + this.targetServiceName = targetServiceName; + } + public static Builder newBuilder() { return new Builder(); } @@ -44,12 +35,12 @@ public class ErrorLogOptionalData { } public Builder targetEntity(String targetEntity) { - instance.targetEntity = targetEntity; + instance.setTargetEntity(targetEntity); return this; } public Builder targetServiceName(String targetServiceName) { - instance.targetServiceName = targetServiceName; + instance.setTargetServiceName(targetServiceName); return this; } diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java index 361c255009..eb1646c612 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java @@ -1,29 +1,9 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.apache.commons.lang3.StringUtils; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.openecomp.sdc.common.log.api.LogConfigurationConstants; import org.openecomp.sdc.common.log.enums.ConstantsLogging; +import org.openecomp.sdc.common.log.api.ILogConfiguration; import org.openecomp.sdc.common.log.api.ILogFieldsHandler; import org.openecomp.sdc.common.log.enums.Severity; import org.slf4j.Logger; @@ -37,6 +17,8 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; +import static java.lang.Integer.valueOf; + public class LogFieldsMdcHandler implements ILogFieldsHandler { private static LogFieldsMdcHandler instanceMdcWrapper = new LogFieldsMdcHandler(); @@ -50,7 +32,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { .ofPattern(dateFormatPattern); protected static Logger log = LoggerFactory.getLogger(LogFieldsMdcHandler.class.getName()); protected static String hostAddress; - private static String fqdn; + protected static String fqdn; static { try { @@ -79,7 +61,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { public void stopAuditTimer() { //set start time if it is not set yet startAuditTimer(); - MDC.put(LogConfigurationConstants.MDC_END_TIMESTAMP, generatedTimeNow()); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); setElapsedTime(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); } @@ -87,13 +69,13 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { public void stopMetricTimer() { //set start time if it is not set yet startMetricTimer(); - MDC.put(LogConfigurationConstants.MDC_END_TIMESTAMP, generatedTimeNow()); + MDC.put(ILogConfiguration.MDC_END_TIMESTAMP, generatedTimeNow()); setElapsedTime(MDC.get(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP)); } @Override public void setClassName(String className) { - MDC.put(LogConfigurationConstants.MDC_CLASS_NAME, className); + MDC.put(ILogConfiguration.MDC_CLASS_NAME, className); } @Override @@ -103,7 +85,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setServerIPAddress(String serverIPAddress) { - MDC.put(LogConfigurationConstants.MDC_SERVER_IP_ADDRESS, serverIPAddress); + MDC.put(ILogConfiguration.MDC_SERVER_IP_ADDRESS, serverIPAddress); } @Override @@ -123,7 +105,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setProcessKey(String processKey) { - MDC.put(LogConfigurationConstants.MDC_PROCESS_KEY, processKey); + MDC.put(ILogConfiguration.MDC_PROCESS_KEY, processKey); } @Override @@ -133,12 +115,12 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setOptCustomField1(String customField1) { - MDC.put(LogConfigurationConstants.MDC_OPT_FIELD1, customField1); + MDC.put(ILogConfiguration.MDC_OPT_FIELD1, customField1); } @Override public void setOutgoingInvocationId(String outgoingInvocationId) { - MDC.put(LogConfigurationConstants.MDC_OUTGOING_INVOCATION_ID, outgoingInvocationId); + MDC.put(ILogConfiguration.MDC_OUTGOING_INVOCATION_ID, outgoingInvocationId); } @Override @@ -155,7 +137,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setRemoteHost(String remoteHost) { - MDC.put(LogConfigurationConstants.MDC_REMOTE_HOST, remoteHost); + MDC.put(ILogConfiguration.MDC_REMOTE_HOST, remoteHost); } @Override @@ -185,7 +167,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setServiceInstanceId(String serviceInstanceId) { - MDC.put(LogConfigurationConstants.MDC_SERVICE_INSTANCE_ID, serviceInstanceId); + MDC.put(ILogConfiguration.MDC_SERVICE_INSTANCE_ID, serviceInstanceId); } @Override @@ -200,22 +182,22 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setTargetVirtualEntity(String targetVirtualEntity) { - MDC.put(LogConfigurationConstants.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); + MDC.put(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY, targetVirtualEntity); } @Override public void setErrorCode(int errorCode) { - MDC.put(LogConfigurationConstants.MDC_ERROR_CODE, Integer.toString(errorCode)); + MDC.put(ILogConfiguration.MDC_ERROR_CODE, valueOf(errorCode).toString()); } @Override public void setErrorCategory(String errorCategory) { - MDC.put(LogConfigurationConstants.MDC_ERROR_CATEGORY, errorCategory); + MDC.put(ILogConfiguration.MDC_ERROR_CATEGORY, errorCategory); } @Override public String getErrorCode() { - return MDC.get(LogConfigurationConstants.MDC_ERROR_CODE); + return MDC.get(ILogConfiguration.MDC_ERROR_CODE); } @Override @@ -225,7 +207,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public String getErrorCategory() { - return MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY); + return MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY); } @Override @@ -285,7 +267,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void removeServiceInstanceId() { - MDC.remove(LogConfigurationConstants.MDC_SERVICE_INSTANCE_ID); + MDC.remove(ILogConfiguration.MDC_SERVICE_INSTANCE_ID); } @Override @@ -300,81 +282,87 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void removeTargetVirtualEntity() { - MDC.remove(LogConfigurationConstants.MDC_TARGET_VIRTUAL_ENTITY); + MDC.remove(ILogConfiguration.MDC_TARGET_VIRTUAL_ENTITY); } @Override public void removeErrorCode() { - MDC.remove(LogConfigurationConstants.MDC_ERROR_CODE); + MDC.remove(ILogConfiguration.MDC_ERROR_CODE); } @Override public void removeErrorCategory() { - MDC.remove(LogConfigurationConstants.MDC_ERROR_CATEGORY); + MDC.remove(ILogConfiguration.MDC_ERROR_CATEGORY); } @Override public void removeErrorDescription() { - MDC.remove(LogConfigurationConstants.MDC_ERROR_DESC); + MDC.remove(ILogConfiguration.MDC_ERROR_DESC); } @Override public void setAuditMessage(String message) { - MDC.put(LogConfigurationConstants.MDC_AUDIT_MESSAGE, message); + MDC.put(ILogConfiguration.MDC_AUDIT_MESSAGE, message); } @Override public String getAuditMessage() { - return MDC.get(LogConfigurationConstants.MDC_AUDIT_MESSAGE); + return MDC.get(ILogConfiguration.MDC_AUDIT_MESSAGE); } + @Override public String getSupportablityStatusCode() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_STATUS_CODE); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_STATUS_CODE); } @Override public String getSupportablityAction() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_ACTION); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_ACTION); } @Override public String getRemoteHost() { - return MDC.get(LogConfigurationConstants.MDC_REMOTE_HOST); + return MDC.get(ILogConfiguration.MDC_REMOTE_HOST); } @Override public String getServerIpAddress() { - return MDC.get(LogConfigurationConstants.MDC_SERVER_IP_ADDRESS); + return MDC.get(ILogConfiguration.MDC_SERVER_IP_ADDRESS); } +// @Override +// public String getSupportablityCsarName() { +// return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_NAME); +// } + @Override public String getSupportablityCsarUUID() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_UUID); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID); } @Override public String getSupportablityCsarVersion() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_VERSION); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION); } @Override public String getSupportablityComponentName() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_NAME); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME); } @Override public String getSupportablityComponentUUID() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_UUID); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID); } @Override public String getSupportablityComponentVersion() { - return MDC.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_VERSION); + return MDC.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION); } @Override @@ -384,72 +372,77 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { @Override public void setSupportablityStatusCode(String statusCode) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_STATUS_CODE, statusCode); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_STATUS_CODE, statusCode); } @Override public void setSupportablityAction(String action) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_ACTION, action); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_ACTION, action); } @Override public void setSupportablityCsarUUID(String uuid) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_UUID, uuid); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID, uuid); } @Override public void setSupportablityCsarVersion(String version) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_VERSION, version); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION, version); } @Override public void setSupportablityComponentName(String name) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_NAME, name); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, name); } @Override public void setSupportablityComponentUUID(String uuid) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_UUID, uuid); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, uuid); } @Override public void setSupportablityComponentVersion(String version) { - MDC.put(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_VERSION, version); + MDC.put(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, version); } @Override public void removeSupportablityAction() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_ACTION); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_ACTION); } @Override public void removeSupportablityComponentName() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_NAME); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME); } @Override public void removeSupportablityComponentUUID() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_UUID); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID); } @Override public void removeSupportablityComponentVersion() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_VERSION); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION); } +// @Override +// public void removeSupportablityCsarName() { +// MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_NAME); +// } + @Override public void removeSupportablityCsarUUID() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_UUID); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID); } @Override public void removeSupportablityCsarVersion() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_VERSION); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION); } @Override public void removeSupportablityStatusCode() { - MDC.remove(LogConfigurationConstants.MDC_SUPPORTABLITY_STATUS_CODE); + MDC.remove(ILogConfiguration.MDC_SUPPORTABLITY_STATUS_CODE); } @Override @@ -461,10 +454,10 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler { try { final LocalDateTime startTime = LocalDateTime.parse(beginTimestamp, dateTimeFormatter); final LocalDateTime endTime = LocalDateTime - .parse(MDC.get(LogConfigurationConstants.MDC_END_TIMESTAMP), dateTimeFormatter); + .parse(MDC.get(ILogConfiguration.MDC_END_TIMESTAMP), dateTimeFormatter); final Duration timeDifference = Duration.between(startTime, endTime); - MDC.put(LogConfigurationConstants.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); + MDC.put(ILogConfiguration.MDC_ELAPSED_TIME, String.valueOf(timeDifference.toMillis())); } catch (Exception ex) { log.error("failed to calculate elapsed time", ex); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java index 502b7a6871..771ecfd9d4 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerAudit.java @@ -1,27 +1,8 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.openecomp.sdc.common.log.api.LogConfigurationConstants; +import org.openecomp.sdc.common.log.api.ILogConfiguration; import org.openecomp.sdc.common.log.api.ILogFieldsHandler; import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; import org.openecomp.sdc.common.log.enums.Severity; @@ -35,30 +16,30 @@ import java.util.Collections; import java.util.List; public class LoggerAudit extends LoggerBase { - private static List<String> mandatoryFields = new ArrayList<>(Arrays.asList( + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( ONAPLogConstants.MDCs.ENTRY_TIMESTAMP, - LogConfigurationConstants.MDC_END_TIMESTAMP, + ILogConfiguration.MDC_END_TIMESTAMP, ONAPLogConstants.MDCs.REQUEST_ID, ONAPLogConstants.MDCs.SERVICE_NAME, ONAPLogConstants.MDCs.PARTNER_NAME, ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.MDCs.RESPONSE_CODE, - LogConfigurationConstants.MDC_SERVICE_INSTANCE_ID, + ILogConfiguration.MDC_SERVICE_INSTANCE_ID, ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, - LogConfigurationConstants.MDC_ELAPSED_TIME, - LogConfigurationConstants.MDC_SERVER_IP_ADDRESS, + ILogConfiguration.MDC_ELAPSED_TIME, + ILogConfiguration.MDC_SERVER_IP_ADDRESS, ONAPLogConstants.MDCs.SERVER_FQDN)); - private static List<String> optionalFields = new ArrayList<>(Arrays.asList( + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( ONAPLogConstants.MDCs.INSTANCE_UUID, ONAPLogConstants.MDCs.RESPONSE_SEVERITY, - LogConfigurationConstants.MDC_REMOTE_HOST, - LogConfigurationConstants.MDC_CLASS_NAME, - LogConfigurationConstants.MDC_PROCESS_KEY, - LogConfigurationConstants.MDC_OPT_FIELD1, - LogConfigurationConstants.MDC_OPT_FIELD2, - LogConfigurationConstants.MDC_OPT_FIELD3, - LogConfigurationConstants.MDC_OPT_FIELD4)); + ILogConfiguration.MDC_REMOTE_HOST, + ILogConfiguration.MDC_CLASS_NAME, + ILogConfiguration.MDC_PROCESS_KEY, + ILogConfiguration.MDC_OPT_FIELD1, + ILogConfiguration.MDC_OPT_FIELD2, + ILogConfiguration.MDC_OPT_FIELD3, + ILogConfiguration.MDC_OPT_FIELD4)); LoggerAudit(ILogFieldsHandler ecompMdcWrapper, Logger logger) { //TODO Andrey, set default marker @@ -85,7 +66,7 @@ public class LoggerAudit extends LoggerBase { } public LoggerAudit setOptClassName(String className) { - MDC.put(LogConfigurationConstants.MDC_CLASS_NAME, className); + MDC.put(ILogConfiguration.MDC_CLASS_NAME, className); return this; } diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java index 5b2bfad5b9..4ee6039d32 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerBase.java @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 com.google.common.annotations.VisibleForTesting; @@ -38,6 +18,12 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; + +/** + * Created by mm288v on 12/27/2017. + * This class holds the common behavior of all Loger-Typed classes. + * The Concrete loggers shoudl derive from this one. + */ public abstract class LoggerBase implements ILogger { private final Logger myLogger; private final Marker myMarker; diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java index dc8c4b4c16..cebe7bac51 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerDebug.java @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.onap.logging.ref.slf4j.ONAPLogConstants; @@ -33,7 +13,7 @@ import java.util.List; public class LoggerDebug extends LoggerBase { - private static List<String> mandatoryFields = new ArrayList<>(Arrays.asList(ONAPLogConstants.MDCs.REQUEST_ID)); + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList(ONAPLogConstants.MDCs.REQUEST_ID)); LoggerDebug(ILogFieldsHandler ecompMdcWrapper, Logger logger) { super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), logger); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java index a38f16df98..fbf610638b 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerError.java @@ -1,28 +1,8 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.apache.commons.lang3.StringUtils; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.openecomp.sdc.common.log.api.LogConfigurationConstants; +import org.openecomp.sdc.common.log.api.ILogConfiguration; import org.openecomp.sdc.common.log.api.ILogFieldsHandler; import org.openecomp.sdc.common.log.enums.EcompErrorSeverity; import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; @@ -40,8 +20,8 @@ public class LoggerError extends LoggerBase { private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( ONAPLogConstants.MDCs.REQUEST_ID, ONAPLogConstants.MDCs.SERVICE_NAME, - LogConfigurationConstants.MDC_ERROR_CATEGORY, - LogConfigurationConstants.MDC_ERROR_CODE)); + ILogConfiguration.MDC_ERROR_CATEGORY, + ILogConfiguration.MDC_ERROR_CODE)); public static final String defaultServiceName = "SDC catalog"; diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java index 59e2777966..f2f33b2457 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerFactory.java @@ -1,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.slf4j.Logger; @@ -35,19 +15,19 @@ public class LoggerFactory { @SuppressWarnings("unchecked") public static <T, V> V getLogger(Class<T> type, Logger logger) { - if (type.getName().equals(LoggerAudit.class.getName())) { + if (type.isAssignableFrom(LoggerAudit.class)) { return (V) new LoggerAudit(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerDebug.class.getName())) { + if (type.isAssignableFrom(LoggerDebug.class)) { return (V) new LoggerDebug(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerMetric.class.getName())) { + if (type.isAssignableFrom(LoggerMetric.class)) { return (V) new LoggerMetric(new LogFieldsMdcHandler(), logger); } - if (type.getName().equals(LoggerError.class.getName())) { + if (type.isAssignableFrom(LoggerError.class)) { return (V) new LoggerError(new LogFieldsMdcHandler(), logger); } @@ -57,19 +37,19 @@ public class LoggerFactory { @SuppressWarnings("unchecked") public static <T, V> V getMdcLogger(Class<T> type, Logger logger) { - if (type.getName().equals(LoggerAudit.class.getName())) { + if (type.isAssignableFrom(LoggerAudit.class)) { return (V) new LoggerAudit(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerDebug.class.getName())) { + if (type.isAssignableFrom(LoggerDebug.class)) { return (V) new LoggerDebug(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerMetric.class.getName())) { + if (type.isAssignableFrom(LoggerMetric.class)) { return (V) new LoggerMetric(LogFieldsMdcHandler.getInstance(), logger); } - if (type.getName().equals(LoggerError.class.getName())) { + if (type.isAssignableFrom(LoggerError.class)) { return (V) new LoggerError(LogFieldsMdcHandler.getInstance(), logger); } 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 3dbcf1dde3..8af85ea1a3 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,23 +1,3 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.openecomp.sdc.common.log.api.ILogFieldsHandler; @@ -33,11 +13,11 @@ 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.LogConfigurationConstants.*; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; public class LoggerMetric extends LoggerBase { - private static List<String> mandatoryFields = new ArrayList<>(Arrays.asList( + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( INVOKE_TIMESTAMP, MDC_END_TIMESTAMP, REQUEST_ID, @@ -51,7 +31,7 @@ public class LoggerMetric extends LoggerBase { MDC_SERVER_IP_ADDRESS, SERVER_FQDN)); - private static List<String> optionalFields = new ArrayList<>(Arrays.asList( + private static ArrayList<String> optionalFields = new ArrayList<>(Arrays.asList( MDC_TARGET_VIRTUAL_ENTITY, TARGET_ENTITY, TARGET_SERVICE_NAME, diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerSupportability.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerSupportability.java index 849add3625..b3b91b96be 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerSupportability.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LoggerSupportability.java @@ -1,26 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 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. - * 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 org.openecomp.sdc.common.log.api.LogConfigurationConstants; +import org.openecomp.sdc.common.log.api.ILogConfiguration; import org.openecomp.sdc.common.log.api.ILogFieldsHandler; import org.openecomp.sdc.common.log.enums.LogLevel; import org.openecomp.sdc.common.log.enums.LogMarkers; @@ -53,23 +33,23 @@ public class LoggerSupportability extends LoggerBase { log(action, null, statusCode, message, params); } - private static List<String> mandatoryFields = new ArrayList<>(Arrays.asList( - LogConfigurationConstants.MDC_SUPPORTABLITY_ACTION, - LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_UUID, - LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_VERSION, - LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_NAME, - LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_UUID, - LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_VERSION, - LogConfigurationConstants.MDC_SUPPORTABLITY_STATUS_CODE)); + private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList( + ILogConfiguration.MDC_SUPPORTABLITY_ACTION, + ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID, + ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION, + ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME, + ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID, + ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION, + ILogConfiguration.MDC_SUPPORTABLITY_STATUS_CODE)); private void fillFieldsBeforeLogging(LoggerSupportabilityActions action, Map<String,String> componentMetaData,StatusCode statusCode) { clear(); if (componentMetaData!=null){ - ecompLogFieldsHandler.setSupportablityCsarUUID(componentMetaData.get(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_UUID)); - ecompLogFieldsHandler.setSupportablityCsarVersion(componentMetaData.get(LogConfigurationConstants.MDC_SUPPORTABLITY_CSAR_VERSION)); - ecompLogFieldsHandler.setSupportablityComponentName(componentMetaData.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_NAME)); - ecompLogFieldsHandler.setSupportablityComponentUUID(componentMetaData.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_UUID)); - ecompLogFieldsHandler.setSupportablityComponentVersion(componentMetaData.get(LogConfigurationConstants.MDC_SUPPORTABLITY_COMPONENT_VERSION)); + ecompLogFieldsHandler.setSupportablityCsarUUID(componentMetaData.get(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_UUID)); + ecompLogFieldsHandler.setSupportablityCsarVersion(componentMetaData.get(ILogConfiguration.MDC_SUPPORTABLITY_CSAR_VERSION)); + ecompLogFieldsHandler.setSupportablityComponentName(componentMetaData.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_NAME)); + ecompLogFieldsHandler.setSupportablityComponentUUID(componentMetaData.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_UUID)); + ecompLogFieldsHandler.setSupportablityComponentVersion(componentMetaData.get(ILogConfiguration.MDC_SUPPORTABLITY_COMPONENT_VERSION)); } ecompLogFieldsHandler.setSupportablityAction(action.getName()); ecompLogFieldsHandler.setSupportablityStatusCode(statusCode.getStatusCodeEnum()); |