2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.logging.context.impl;
23 import org.openecomp.sdc.logging.context.MdcData;
24 import org.openecomp.sdc.logging.types.LoggerConstants;
28 public class MdcDataErrorMessage extends MdcData {
29 private String targetEntity;
30 private String targetServiceName;
31 private String errorDescription;
34 * Instantiates a new Mdc data error message.
36 * @param targetEntity the target entity
37 * @param targetServiceName the target service name
38 * @param errorCategory the error category
39 * @param errorCode the error code
40 * @param errorDescription the error description
42 public MdcDataErrorMessage(String targetEntity, String targetServiceName, String errorCategory,
43 String errorCode, String errorDescription) {
44 super(errorCategory, errorCode);
45 this.targetEntity = targetEntity;
46 this.targetServiceName = targetServiceName;
47 this.errorDescription = errorDescription;
53 * Create error message and update mdc.
55 * @param targetEntity the target entity
56 * @param targetServiceName the target service name
57 * @param level the level
58 * @param errorCode the error code
59 * @param errorDescription the error description
61 public static void createErrorMessageAndUpdateMdc(String targetEntity, String targetServiceName,
62 String level, String errorCode,
63 String errorDescription) {
64 MdcDataErrorMessage mdcDataErrorMessage =
65 new MdcDataErrorMessage(targetEntity, targetServiceName, level, errorCode,
70 public void setMdcValues() {
72 MDC.put(LoggerConstants.TARGET_ENTITY, this.targetEntity);
73 MDC.put(LoggerConstants.TARGET_SERVICE_NAME, this.targetServiceName);
74 MDC.put(LoggerConstants.ERROR_DESCRIPTION, this.errorDescription);