| 1 | package org.cardanofoundation.explorer.api.config; | |
| 2 | ||
| 3 | import lombok.extern.log4j.Log4j2; | |
| 4 | ||
| 5 | import org.springframework.stereotype.Component; | |
| 6 | ||
| 7 | import org.aspectj.lang.ProceedingJoinPoint; | |
| 8 | import org.aspectj.lang.annotation.Around; | |
| 9 | import org.aspectj.lang.annotation.Aspect; | |
| 10 | ||
| 11 | @Aspect | |
| 12 | @Component | |
| 13 | @Log4j2 | |
| 14 | public class LoggerAspect { | |
| 15 | ||
| 16 | @Around("@annotation(LogMessage)") | |
| 17 | public Object aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable { | |
| 18 | String methodName = joinPoint.getSignature().getName(); | |
| 19 | String className = joinPoint.getTarget().getClass().getName(); | |
| 20 | log.info("Method {} in {} has started!!!!!", methodName, className); | |
| 21 | try { | |
| 22 | long startTime = System.currentTimeMillis(); | |
| 23 | Object value = joinPoint.proceed(); | |
| 24 | long endTime = System.currentTimeMillis(); | |
| 25 | log.info("Method {} in {} running in {} ms", methodName, className, (endTime - startTime)); | |
| 26 |
1
1. aroundAdvice : replaced return value with null for org/cardanofoundation/explorer/api/config/LoggerAspect::aroundAdvice → NO_COVERAGE |
return value; |
| 27 | } finally { | |
| 28 | log.info("Method {} in {} has ended!!!!!", methodName, className); | |
| 29 | } | |
| 30 | } | |
| 31 | } | |
Mutations | ||
| 26 |
1.1 |