2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
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============================================
20 * ===================================================================
24 package org.onap.clamp.flow.log;
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
29 import javax.servlet.http.HttpServletRequest;
31 import org.apache.camel.Exchange;
32 import org.onap.clamp.clds.util.LoggingUtils;
33 import org.onap.clamp.clds.util.ONAPLogConstants;
34 import org.slf4j.event.Level;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.http.HttpStatus;
37 import org.springframework.stereotype.Component;
40 * The Flow log operations.
43 public class FlowLogOperation {
45 protected static final EELFLogger logger = EELFManager.getInstance().getLogger(FlowLogOperation.class);
46 protected static final EELFLogger auditLogger = EELFManager.getInstance().getMetricsLogger();
47 private LoggingUtils util = new LoggingUtils(logger);
50 private HttpServletRequest request;
53 * Generate the entry log.
55 * @param serviceDesc The service description
58 public void startLog(Exchange exchange, String serviceDesc) {
59 util.entering(request, serviceDesc);
60 exchange.getIn().setHeader(ONAPLogConstants.Headers.REQUEST_ID,
61 util.getProperties(ONAPLogConstants.MDCs.REQUEST_ID));
62 exchange.getIn().setHeader(ONAPLogConstants.Headers.INVOCATION_ID,
63 util.getProperties(ONAPLogConstants.MDCs.INVOCATION_ID));
64 exchange.getIn().setHeader(ONAPLogConstants.Headers.PARTNER_NAME,
65 util.getProperties(ONAPLogConstants.MDCs.PARTNER_NAME));
69 * Generate the exiting log.
71 public void endLog() {
72 util.exiting(HttpStatus.OK.toString(), "Successful", Level.INFO,
73 ONAPLogConstants.ResponseStatus.COMPLETED);
77 * Generate the error exiting log.
79 public void errorLog() {
80 util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "Failed",
81 Level.INFO, ONAPLogConstants.ResponseStatus.ERROR);
85 * Generate the error exiting log.
87 public void httpErrorLog() {
92 * Generate the invoke log.
94 public void invokeLog(String targetEntity, String targetServiceName) {
95 util.invoke(targetEntity, targetServiceName);
99 * Generate the invoke return marker.
101 public void invokeReturnLog() {