- final StopWatch stopWatch = new StopWatch();
-
- //Calculate method execution time
- stopWatch.start();
- final Object logObject = Optional.ofNullable(proceedingJoinPoint.proceed()).orElse("");
- stopWatch.stop();
- final MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
- //Log method execution time
- log.debug("Execution time of : {}.{}() with argument[s] = {} having result = {} :: {} ms",
- methodSignature.getDeclaringType().getSimpleName(),
- methodSignature.getName(), Arrays.toString(proceedingJoinPoint.getArgs()), logObject,
- stopWatch.getTotalTimeMillis());
+ if (isSlf4JDebugEnabled()) {
+ final StopWatch stopWatch = new StopWatch();
+ //Calculate method execution time
+ stopWatch.start();
+ final Object returnValue = proceedingJoinPoint.proceed();
+ stopWatch.stop();
+ final MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
+ //Log method execution time
+ log.debug("Execution time of : {}.{}() with argument[s] = {} having result = {} :: {} ms",
+ methodSignature.getDeclaringType().getSimpleName(),
+ methodSignature.getName(), Arrays.toString(proceedingJoinPoint.getArgs()), returnValue,
+ stopWatch.getTotalTimeMillis());
+ return returnValue;
+ }
+ return proceedingJoinPoint.proceed();
+ }