2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.aai.aailog.logs;
24 import java.util.UUID;
26 import javax.ws.rs.core.Response;
28 import org.onap.logging.filter.base.MDCSetup;
29 import org.onap.logging.ref.slf4j.ONAPLogConstants;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
34 import org.springframework.context.annotation.Scope;
35 import org.springframework.stereotype.Component;
38 @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
39 public class AaiScheduledTaskAuditLog extends MDCSetup {
40 protected static Logger logger = LoggerFactory.getLogger(AaiScheduledTaskAuditLog.class);
42 public void logBefore(String serviceName, String partnerName) {
44 String requestId = UUID.randomUUID().toString();
45 MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
46 setInvocationIdFromMDC();
47 MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
48 MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
50 setClientIPAddress(null);
53 MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
56 logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
57 } catch (Exception e) {
58 logger.warn("Error in AaiScheduledTaskAuditLog logBefore", e.getMessage());
63 public void logAfter() {
65 // TODO: how do we know if there was an error
66 setResponseStatusCode(Response.Status.OK.getStatusCode());
69 logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
70 } catch (Exception e) {
71 logger.warn("Error in AaiScheduledTaskAuditLog logAfter", e.getMessage());