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=========================================================
21 package org.onap.aai.aailog.logs;
23 import org.onap.logging.filter.base.MDCSetup;
24 import org.onap.logging.ref.slf4j.ONAPLogConstants;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
29 import org.springframework.context.annotation.Scope;
30 import org.springframework.stereotype.Component;
32 import javax.ws.rs.core.Response;
33 import java.util.UUID;
36 @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
37 public class AaiScheduledTaskAuditLog extends MDCSetup {
38 protected static Logger logger = LoggerFactory.getLogger(AaiScheduledTaskAuditLog.class);
40 public void logBefore(String serviceName, String partnerName) {
42 String requestId = UUID.randomUUID().toString();
43 MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
44 setInvocationIdFromMDC();
45 MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, serviceName);
46 MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
48 setClientIPAddress(null);
51 MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
54 logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
55 } catch (Exception e) {
56 logger.warn("Error in AaiScheduledTaskAuditLog logBefore", e.getMessage());
61 public void logAfter() {
63 // TODO: how do we know if there was an error
64 setResponseStatusCode(Response.Status.OK.getStatusCode());
67 logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
68 } catch (Exception e) {
69 logger.warn("Error in AaiScheduledTaskAuditLog logAfter", e.getMessage());