Refactoring Consolidation Service
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / ecomplog / EcompLoggerError.java
1 package org.openecomp.sdc.common.ecomplog;
2
3 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_BEGIN_TIMESTAMP;
4 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CATEGORY;
5 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_CODE;
6 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_ERROR_DESC;
7 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_KEY_REQUEST_ID;
8 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_PARTNER_NAME;
9 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_SERVICE_NAME;
10 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_ENTITY;
11 import static org.openecomp.sdc.common.ecomplog.api.IEcompLogConfiguration.MDC_TARGET_SERVICE_NAME;
12
13 import org.openecomp.sdc.common.ecomplog.Enums.EcompLoggerErrorCode;
14 import org.openecomp.sdc.common.ecomplog.Enums.LogMarkers;
15 import org.openecomp.sdc.common.ecomplog.api.IEcompMdcWrapper;
16 import org.slf4j.MarkerFactory;
17
18 public class EcompLoggerError extends EcompLoggerBase{
19     private static EcompLoggerError instanceLoggerError = EcompLoggerFactory.getLogger(EcompLoggerError.class);
20
21     EcompLoggerError(IEcompMdcWrapper ecompMdcWrapper) {
22         super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.ERROR_MARKER.text()));
23     }
24
25     public static EcompLoggerError getInstance() {
26         return instanceLoggerError;
27     }
28
29     @Override
30     public void initializeMandatoryFields() {
31         ecompMdcWrapper.setMandatoryField(MDC_BEGIN_TIMESTAMP);
32         ecompMdcWrapper.setMandatoryField(MDC_KEY_REQUEST_ID);
33         ecompMdcWrapper.setMandatoryField(MDC_SERVICE_NAME);
34         ecompMdcWrapper.setMandatoryField(MDC_PARTNER_NAME);
35         ecompMdcWrapper.setMandatoryField(MDC_ERROR_CATEGORY);
36         ecompMdcWrapper.setMandatoryField(MDC_ERROR_CODE);
37         ecompMdcWrapper.setMandatoryField(MDC_ERROR_DESC);
38
39         ecompMdcWrapper.setOptionalField(MDC_TARGET_ENTITY);
40         ecompMdcWrapper.setOptionalField(MDC_TARGET_SERVICE_NAME);
41     }
42
43     @Override
44     public EcompLoggerError startTimer() {
45         return (EcompLoggerError) super.startTimer();
46     }
47
48     @Override
49     public EcompLoggerError setKeyRequestId(String keyRequestId) {
50         return (EcompLoggerError) super.setKeyRequestId(keyRequestId);
51     }
52
53     public EcompLoggerError setServiceName(String serviceName) {
54         ecompMdcWrapper.setServiceName(serviceName);
55         return this;
56     }
57
58     public EcompLoggerError setTargetEntity(String targetEntity) {
59         ecompMdcWrapper.setTargetEntity(targetEntity);
60         return this;
61     }
62
63     public EcompLoggerError setErrorCode(EcompLoggerErrorCode errorCode) {
64         ecompMdcWrapper.setErrorCode(errorCode.getErrorCode());
65         return this;
66     }
67
68     public EcompLoggerError setErrorDescription(String errorDescription) {
69         ecompMdcWrapper.setErrorDescription(errorDescription);
70         return this;
71     }
72
73     public EcompLoggerError clear() {
74         return (EcompLoggerError) super.clear();
75     }
76
77 }