diff options
Diffstat (limited to 'common-app-logging/src')
34 files changed, 282 insertions, 746 deletions
diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java new file mode 100644 index 0000000000..6862fdddc3 --- /dev/null +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogConfiguration.java @@ -0,0 +1,29 @@ +package org.openecomp.sdc.common.log.api; + +public interface ILogConfiguration { + + String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceID"; + String MDC_SERVER_IP_ADDRESS = "ServerIPAddress"; + String MDC_REMOTE_HOST = "RemoteHost"; + String MDC_AUDIT_MESSAGE = "AuditMessage"; + String MDC_END_TIMESTAMP = "EndTimestamp"; + String MDC_ELAPSED_TIME = "ElapsedTime"; + String MDC_PROCESS_KEY = "ProcessKey"; + 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"; + String MDC_OUTGOING_INVOCATION_ID = "OutgoingInvocationId"; + String MDC_SUPPORTABLITY_ACTION = "SupportablityAction"; + String MDC_SUPPORTABLITY_CSAR_UUID="SupportablityCsarUUID"; + String MDC_SUPPORTABLITY_CSAR_VERSION="SupportablityCsarVersion"; + String MDC_SUPPORTABLITY_COMPONENT_NAME = "SupportablityComponentName"; + String MDC_SUPPORTABLITY_COMPONENT_UUID = "SupportablityComponentUUID"; + String MDC_SUPPORTABLITY_COMPONENT_VERSION="SupportablityComponentVersion"; + String MDC_SUPPORTABLITY_STATUS_CODE = "SupportablityStatus"; +}
\ No newline at end of file diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java index 7d1783314f..ed1a19d76d 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogFieldsHandler.java @@ -1,27 +1,10 @@ -/*- - * ============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.api; import org.openecomp.sdc.common.log.enums.Severity; +/** + * Created by dd4296 on 12/25/2017. + */ public interface ILogFieldsHandler { void startAuditTimer(); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java index 866498cefd..9a2ad6960a 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/ILogger.java @@ -1,22 +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.api; import org.openecomp.sdc.common.log.enums.LogLevel; @@ -24,6 +5,9 @@ import org.slf4j.Marker; import java.util.List; +/** + * Created by dd4296 on 12/24/2017. + */ public interface ILogger { void log(LogLevel logLevel, String message); void log(Marker marker, LogLevel logLevel, String message); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/LogConfigurationConstants.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/LogConfigurationConstants.java deleted file mode 100644 index d1d5a3af7c..0000000000 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/api/LogConfigurationConstants.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============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.api; - -public final class LogConfigurationConstants { - - public static final String MDC_SERVICE_INSTANCE_ID = "ServiceInstanceID"; - public static final String MDC_SERVER_IP_ADDRESS = "ServerIPAddress"; - public static final String MDC_REMOTE_HOST = "RemoteHost"; - public static final String MDC_AUDIT_MESSAGE = "AuditMessage"; - public static final String MDC_END_TIMESTAMP = "EndTimestamp"; - public static final String MDC_ELAPSED_TIME = "ElapsedTime"; - public static final String MDC_PROCESS_KEY = "ProcessKey"; - public static final String MDC_TARGET_VIRTUAL_ENTITY = "TargetVirtualEntity"; - public static final String MDC_ERROR_CATEGORY = "ErrorCategory"; - public static final String MDC_ERROR_CODE = "ErrorCode"; - public static final String MDC_ERROR_DESC = "ErrorDescription"; - public static final String MDC_CLASS_NAME = "ClassName"; - public static final String MDC_OPT_FIELD1 = "CustomField1"; - public static final String MDC_OPT_FIELD2 = "CustomField2"; - public static final String MDC_OPT_FIELD3 = "CustomField3"; - public static final String MDC_OPT_FIELD4 = "CustomField4"; - public static final String MDC_OUTGOING_INVOCATION_ID = "OutgoingInvocationId"; - public static final String MDC_SUPPORTABLITY_ACTION = "SupportablityAction"; - public static final String MDC_SUPPORTABLITY_CSAR_UUID = "SupportablityCsarUUID"; - public static final String MDC_SUPPORTABLITY_CSAR_VERSION = "SupportablityCsarVersion"; - public static final String MDC_SUPPORTABLITY_COMPONENT_NAME = "SupportablityComponentName"; - public static final String MDC_SUPPORTABLITY_COMPONENT_UUID = "SupportablityComponentUUID"; - public static final String MDC_SUPPORTABLITY_COMPONENT_VERSION = "SupportablityComponentVersion"; - public static final String MDC_SUPPORTABLITY_STATUS_CODE = "SupportablityStatus"; -}
\ No newline at end of file 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()); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/ConstantsLogging.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/ConstantsLogging.java index 34606dcebd..025de545a0 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/ConstantsLogging.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/ConstantsLogging.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.enums; public final class ConstantsLogging { diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompErrorSeverity.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompErrorSeverity.java index 4d21d8c8c6..e88a074f0a 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompErrorSeverity.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompErrorSeverity.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.enums; public enum EcompErrorSeverity { diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java index db174b4096..780b24d0e5 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/EcompLoggerErrorCode.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * SDC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 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. diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java index aaee7512bd..5b1ec9d4a9 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogLevel.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * SDC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 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. @@ -17,8 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.openecomp.sdc.common.log.enums; +/** + * Created by dd4296 on 12/14/2017. + */ public enum LogLevel { INFO, WARN, diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java index 7b12ded745..4f98c556e8 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LogMarkers.java @@ -1,25 +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.enums; +/** + * Created by mm288v on 12/27/2017. + * This enum reflects the Marker text in logback.xml file per each ecomp marker + */ public enum LogMarkers { DEBUG_MARKER("DEBUG_MARKER"), ERROR_MARKER("ERROR_MARKER"), diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LoggerSupportabilityActions.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LoggerSupportabilityActions.java index d831700dec..95594a3469 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LoggerSupportabilityActions.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/LoggerSupportabilityActions.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.enums; public enum LoggerSupportabilityActions { diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java index 0e90d57c8e..15a6039f7f 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/Severity.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * SDC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019 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. @@ -20,6 +20,9 @@ package org.openecomp.sdc.common.log.enums; +/** + * Created by dd4296 on 12/14/2017. + */ public enum Severity { OK(0), WARNING(1), diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java index 4ed65df97b..8ede6f9d6e 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/enums/StatusCode.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.enums; public enum StatusCode { diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/EcompLogErrorCode.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/EcompLogErrorCode.java index 9c90529d22..ce33480ca2 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/EcompLogErrorCode.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/EcompLogErrorCode.java @@ -1,31 +1,19 @@ -/*- - * ============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.utils; + public enum EcompLogErrorCode { E_399("Internal Invalid Object. Description: %s"), - E_210("Connection problem towards U-EB server. Reason: %s"); + E_210( + "Connection problem towards U-EB server. Reason: %s"); String description; + String resolution; + + EcompLogErrorCode(String description, String resolution) { + this.description = description; + this.resolution = resolution; + } EcompLogErrorCode(String description) { this.description = description; @@ -39,4 +27,12 @@ public enum EcompLogErrorCode { this.description = description; } -} + public String getResolution() { + return resolution; + } + + public void setResolution(String resolution) { + this.resolution = resolution; + } + + } diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/LoggingThreadLocalsHolder.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/LoggingThreadLocalsHolder.java index 3d7a16b846..c621a2a975 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/LoggingThreadLocalsHolder.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/utils/LoggingThreadLocalsHolder.java @@ -22,9 +22,6 @@ package org.openecomp.sdc.common.log.utils; public class LoggingThreadLocalsHolder { - - private LoggingThreadLocalsHolder() { - } private static final ThreadLocal<String> uuidThreadLocal = new ThreadLocal<>(); diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java index 9c2bfec126..8f733b4f5e 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/Logger.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.wrappers; import com.google.common.annotations.VisibleForTesting; @@ -131,14 +111,13 @@ public class Logger implements org.slf4j.Logger { metric.log(LogLevel.INFO, msg, params); } - public void invoke(String remoteHost, String targetEntity, String targetServiceName, String serviceName, String msg, Object... params) { + public void invoke(String targetEntity, String targetServiceName, String serviceName, String msg, Object... params) { String invocationId = UUID.randomUUID().toString(); String requestID = UUID.randomUUID().toString(); metric.startTimer() .stopTimer() - .setRemoteHost(remoteHost) .setOutgoingInvocationId(invocationId) .setTargetServiceName(targetServiceName) .setTargetEntity(targetEntity) diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java index b2db66ed00..b8c1b268e1 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcAudit.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.wrappers; import org.apache.commons.lang3.StringUtils; diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java index cec429a000..6ca71281d3 100644 --- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.java +++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/wrappers/LoggerSdcUtilBase.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.wrappers; import org.apache.commons.lang3.StringUtils; @@ -31,6 +11,12 @@ import java.util.StringTokenizer; import static java.net.HttpURLConnection.*; +/** + * Created by dd4296 on 12/20/2017. + * + * base class for metric and audit log logging + * holding the specific logic for data extraction + */ public class LoggerSdcUtilBase { protected static Logger log = LoggerFactory.getLogger(LoggerSdcUtilBase.class.getName()); @@ -92,8 +78,9 @@ public class LoggerSdcUtilBase { case HTTP_BAD_METHOD: case HTTP_PROXY_AUTH: return true; - default: return false; } + + return false; } private boolean isDataError(int httpResponseCode) { @@ -106,8 +93,9 @@ public class LoggerSdcUtilBase { case HTTP_ENTITY_TOO_LARGE: case HTTP_UNSUPPORTED_TYPE: return true; - default: return false; } + + return false; } private boolean isSchemaError(int httpResponseCode) { @@ -199,6 +187,9 @@ public class LoggerSdcUtilBase { } private boolean isFound(String value) { - return (StringUtils.isNotEmpty(value)); + if (StringUtils.isNotEmpty(value)) { + return true; + } + return false; } }
\ No newline at end of file diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java index 1634115b06..c6b854ea06 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java @@ -26,7 +26,7 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; import static org.junit.Assert.*; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; public class LogFieldsMdcHandlerTest { diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java index 4b0533ae24..1bd733664e 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAsdcUtilTest.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; @@ -45,16 +25,21 @@ import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; +/** + * Created by dd4296 on 12/19/2017. + * + * test get partner name + */ @RunWith(MockitoJUnitRunner.class) public class LoggerAsdcUtilTest { - private static final String chromeUserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"; - private static final String firefoxUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox"; - private static final String explorerUserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)"; + private final String chromeUserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"; + private final String firefoxUserAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.13) Gecko/20080313 Firefox"; + private final String explorerUserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)"; - private static final String testUserId = "ml007"; - private static final String urlWithUserName = "/api/v1/user/" + testUserId; - private static final String xOnapPartnerName = "ml007"; + private final String testUserId = "ml007"; + private final String urlWithUserName = "/api/v1/user/" + testUserId; + private final String xOnapPartnerName = "ml007"; class SdcEelfAuditTest extends LoggerSdcAudit { diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java index 7ca1cf16cc..8c37e23d97 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerAuditTest.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.junit.After; @@ -38,7 +18,14 @@ import java.net.UnknownHostException; import java.util.UUID; 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.*; +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_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.elements.LogFieldsMdcHandler.hostAddress; import static org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode.DATA_ERROR; diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java index 91e1aab267..b423102cb3 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerBaseTest.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.junit.Test; diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java index 020b55cba6..404f5c1c62 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerDebugTest.java @@ -1,25 +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; +/** + * Created by dd4296 on 12/25/2017. + */ + import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -37,7 +21,7 @@ import java.net.UnknownHostException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; @RunWith(MockitoJUnitRunner.class) public class LoggerDebugTest { diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java index 06376ed48f..8d54397c88 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerErrorTest.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.junit.Before; @@ -34,7 +14,7 @@ import org.slf4j.Logger; import org.slf4j.MDC; import static org.junit.Assert.assertEquals; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CODE; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_ERROR_CODE; @RunWith(MockitoJUnitRunner.class) public class LoggerErrorTest { diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java index 3bd1afcce9..0d8c80797d 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LoggerMetricTest.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.junit.After; @@ -28,6 +8,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.common.log.enums.LogLevel; +import org.openecomp.sdc.common.log.enums.Severity; import org.openecomp.sdc.common.log.utils.LoggingThreadLocalsHolder; import org.slf4j.Logger; import org.slf4j.MDC; @@ -39,7 +20,14 @@ import java.util.UUID; import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.*; import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.*; +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_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 static org.openecomp.sdc.common.log.elements.LogFieldsMdcHandler.hostAddress; /** diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java index fd66efffc7..da721fa4f5 100644 --- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.java +++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/wrappers/LoggerTest.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.wrappers; import org.junit.Before; @@ -29,7 +9,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; 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.elements.ErrorLogOptionalData; import org.openecomp.sdc.common.log.elements.LoggerError; import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode; @@ -46,14 +26,12 @@ import javax.ws.rs.core.UriInfo; import java.net.URI; import java.net.URISyntaxException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.REQUEST_ID; import static org.onap.logging.ref.slf4j.ONAPLogConstants.MDCs.SERVICE_NAME; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CATEGORY; -import static org.openecomp.sdc.common.log.api.LogConfigurationConstants.MDC_ERROR_CODE; +import static org.openecomp.sdc.common.log.api.ILogConfiguration.*; @RunWith(MockitoJUnitRunner.class) public class LoggerTest { @@ -63,6 +41,7 @@ public class LoggerTest { private final static String serviceName = "testService"; private final static String message = "Logger message"; private final static String exceptionMsg= "Exception testing"; + private final static String missingFieldsMessageFragment = "mandatory parameters for ECOMP logging"; @Mock private org.slf4j.Logger logger; @@ -91,8 +70,8 @@ public class LoggerTest { verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); } @@ -104,8 +83,8 @@ public class LoggerTest { verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.AVAILABILITY_TIMEOUTS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); } @@ -117,8 +96,8 @@ public class LoggerTest { verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.FATAL.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.PERMISSION_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.FATAL.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); } @@ -132,8 +111,8 @@ public class LoggerTest { commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -147,8 +126,8 @@ public class LoggerTest { commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -162,8 +141,8 @@ public class LoggerTest { commonLogger.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).warn(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -179,8 +158,8 @@ public class LoggerTest { commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -194,8 +173,8 @@ public class LoggerTest { commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(targetServiceName, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -209,8 +188,8 @@ public class LoggerTest { commonLogger.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, serviceName,errorLogOptionalData, message); verify(logger).error(any(Marker.class), captor.capture(), any(Object[].class)); assertEquals(message, captor.getValue()); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals(targetEntity, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(serviceName, MDC.get(SERVICE_NAME)); assertEquals(null, MDC.get(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME)); @@ -230,8 +209,8 @@ public class LoggerTest { commonLogger.error(message); verify(logger).error(any(Marker.class), eq(message), any(Object[].class)); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.ERROR.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.ERROR.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertNull(MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(LoggerError.defaultServiceName, MDC.get(SERVICE_NAME)); } @@ -268,13 +247,14 @@ public class LoggerTest { @Test public void validateErrorLogWithExceptionWhenErrorSettingsProvidedPartially() { LoggingThreadLocalsHolder.setUuid("uuid"); + final String logFieldsNotProvidedMsg = "mandatory parameters for ECOMP logging, missing fields: ServiceName PartnerName"; when(logger.isWarnEnabled()).thenReturn(true); commonLogger.warn(message, new NullPointerException(exceptionMsg)); //the expected warn message verify(logger).warn(any(Marker.class), contains(message), any(Object[].class)); - assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(LogConfigurationConstants.MDC_ERROR_CODE)); - assertEquals(LogLevel.WARN.name(), MDC.get(LogConfigurationConstants.MDC_ERROR_CATEGORY)); + assertEquals(String.valueOf(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR.getErrorCode()), MDC.get(ILogConfiguration.MDC_ERROR_CODE)); + assertEquals(LogLevel.WARN.name(), MDC.get(ILogConfiguration.MDC_ERROR_CATEGORY)); assertEquals("uuid", MDC.get(REQUEST_ID)); assertNull(MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); assertEquals(LoggerError.defaultServiceName, MDC.get(SERVICE_NAME)); @@ -310,7 +290,7 @@ public class LoggerTest { @Test public void verifyMdcValuesAreStoredWhenAuditAndErrorLoggersAreInvokedSequentially() throws URISyntaxException { final String uuid = "12345"; - final String messageInt = "message"; + final String message = "message"; when(requestContext.getHeaderString(anyString())).thenReturn("ab2222"); when(requestContext.getUriInfo()).thenReturn(uriInfo); when(logger.isErrorEnabled()).thenReturn(true); @@ -323,11 +303,11 @@ public class LoggerTest { LoggerSdcAudit audit = new LoggerSdcAudit(this.getClass()); LoggingThreadLocalsHolder.setUuid(uuid); audit.startLog(requestContext); - audit.logExit("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, messageInt, + audit.logExit("abc.log.com", requestContext, statusType, LogLevel.INFO, Severity.OK, message, MarkerFactory.getMarker(ONAPLogConstants.Markers.EXIT.getName())); - commonLogger.error(messageInt); - verify(logger).error(any(Marker.class), eq(messageInt), any(Object[].class)); + commonLogger.error(message); + verify(logger).error(any(Marker.class), eq(message), any(Object[].class)); assertEquals(uuid, MDC.get(REQUEST_ID)); assertEquals("/", MDC.get(SERVICE_NAME)); assertEquals(LogLevel.ERROR.name(), MDC.get(MDC_ERROR_CATEGORY)); @@ -356,7 +336,7 @@ public class LoggerTest { @Test public void verifyMdcValuesAreStoredWhenTraceLoggerIsInvokedAfterAuditStart() throws URISyntaxException { final String uuid = "12345"; - final String messageInt = "message"; + final String message = "message"; when(requestContext.getHeaderString(anyString())).thenReturn("ab2222"); when(requestContext.getUriInfo()).thenReturn(uriInfo); when(logger.isTraceEnabled()).thenReturn(true); @@ -368,9 +348,9 @@ public class LoggerTest { LoggingThreadLocalsHolder.setUuid(uuid); audit.startLog(requestContext); - commonLogger.trace(messageInt); + commonLogger.trace(message); verify(logger).trace(any(Marker.class), captor.capture(), eq((Object[])null)); - assertEquals(messageInt, captor.getValue()); + assertEquals(message, captor.getValue()); assertEquals(uuid, MDC.get(REQUEST_ID)); } |