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 javax.servlet.http.HttpServletRequest;
27 import org.apache.camel.Exchange;
28 import org.onap.clamp.clds.util.LoggingUtils;
29 import org.onap.clamp.clds.util.OnapLogConstants;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.slf4j.event.Level;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.http.HttpStatus;
35 import org.springframework.stereotype.Component;
38 * The Flow log operations.
41 public class FlowLogOperation {
43 protected static final Logger logger = LoggerFactory.getLogger(FlowLogOperation.class);
44 private LoggingUtils util = new LoggingUtils(logger);
47 private HttpServletRequest request;
50 * Generate the entry log.
53 * The service description the loop name
55 public void startLog(Exchange exchange, String serviceDesc) {
56 util.entering(request, serviceDesc);
57 exchange.setProperty(OnapLogConstants.Headers.REQUEST_ID,
58 util.getProperties(OnapLogConstants.Mdcs.REQUEST_ID));
59 exchange.setProperty(OnapLogConstants.Headers.INVOCATION_ID,
60 util.getProperties(OnapLogConstants.Mdcs.INVOCATION_ID));
61 exchange.setProperty(OnapLogConstants.Headers.PARTNER_NAME,
62 util.getProperties(OnapLogConstants.Mdcs.PARTNER_NAME));
66 * Generate the exiting log.
68 public void endLog() {
69 util.exiting(HttpStatus.OK.value(), "Successful", Level.INFO,
70 OnapLogConstants.ResponseStatus.COMPLETE);
74 * Generate the error exiting log.
76 public void errorLog() {
77 util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.value(), "Failed", Level.INFO,
78 OnapLogConstants.ResponseStatus.ERROR);
82 * Generate the error exiting log.
84 public void httpErrorLog() {
89 * Generate the invoke log.
91 public void invokeLog(String targetEntity, String targetServiceName) {
92 util.invoke(targetEntity, targetServiceName);
96 * Generate the invoke return marker.
98 public void invokeReturnLog() {