CSIT Fix for SDC-2585
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / log / elements / LoggerDebug.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.sdc.common.log.elements;
22
23 import org.openecomp.sdc.common.log.api.ILogConfiguration;
24 import org.openecomp.sdc.common.log.api.ILogFieldsHandler;
25 import org.openecomp.sdc.common.log.enums.LogLevel;
26 import org.openecomp.sdc.common.log.enums.LogMarkers;
27 import org.slf4j.Logger;
28 import org.slf4j.MarkerFactory;
29
30 import java.util.ArrayList;
31 import java.util.Arrays;
32 import java.util.List;
33
34 public class LoggerDebug extends LoggerBase {
35
36     private static ArrayList<String> mandatoryFields = new ArrayList<>(Arrays.asList(ILogConfiguration.MDC_KEY_REQUEST_ID));
37
38     LoggerDebug(ILogFieldsHandler ecompMdcWrapper, Logger logger) {
39         super(ecompMdcWrapper, MarkerFactory.getMarker(LogMarkers.DEBUG_MARKER.text()), logger);
40     }
41
42     @Override
43     public LoggerDebug clear() {
44         //nothing to clean up
45         return this;
46     }
47
48     @Override
49     public void log(LogLevel logLevel, String message, Object... params) {
50         setKeyRequestIdIfNotSetYet();
51         super.log(logLevel, message, params);
52     }
53
54     @Override
55     public void log(LogLevel logLevel, String message, Throwable throwable) {
56         setKeyRequestIdIfNotSetYet();
57         super.log(logLevel, message, throwable);
58     }
59
60     @Override
61     public void log(LogLevel logLevel, String message) {
62         setKeyRequestIdIfNotSetYet();
63         super.log(logLevel, message);
64     }
65
66     @Override
67     public LoggerDebug startTimer() {
68         return this;
69     }
70
71     @Override
72     public List<String> getMandatoryFields() {
73         return mandatoryFields;
74     }
75 }