--- /dev/null
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2020 Nordix Foundation
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
+
+package org.oransc.policyagent.aspect;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.After;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StopWatch;
+
+@Aspect
+@Component
+public class LogAspect {
+
+ private static final Logger logger = LoggerFactory.getLogger(LogAspect.class);
+
+ @Around("execution(* org.oransc.policyagent..*(..)))")
+ public void executimeTime(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
+ MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
+ String className = methodSignature.getDeclaringType().getSimpleName();
+ String methodName = methodSignature.getName();
+ final StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+ proceedingJoinPoint.proceed();
+ stopWatch.stop();
+ logger.trace("Execution time of {}.{}: {} ms", className, methodName, stopWatch.getTotalTimeMillis());
+ }
+
+ @Before("execution(* org.oransc.policyagent..*(..)))")
+ public void entryLog(final JoinPoint joinPoint) throws Throwable {
+ logger.trace("Entering method: {}", joinPoint.getSignature().getName());
+ }
+
+ @After("execution(* org.oransc.policyagent..*(..)))")
+ public void exitLog(final JoinPoint joinPoint) throws Throwable {
+ logger.trace("Exiting method: {}", joinPoint.getSignature().getName());
+ }
+
+}