From 4b2c704bdde27e166009315316c7fe92dfd5b7f2 Mon Sep 17 00:00:00 2001 From: pierre-maraval Date: Fri, 19 Apr 2024 15:55:12 +0200 Subject: [PATCH] Feat : Ajout classe aspect pour intercepter les log --- .../fr/abes/item/logging/LoggingAspect.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 batch/src/main/java/fr/abes/item/logging/LoggingAspect.java diff --git a/batch/src/main/java/fr/abes/item/logging/LoggingAspect.java b/batch/src/main/java/fr/abes/item/logging/LoggingAspect.java new file mode 100644 index 00000000..3fc3c87c --- /dev/null +++ b/batch/src/main/java/fr/abes/item/logging/LoggingAspect.java @@ -0,0 +1,31 @@ +package fr.abes.item.logging; + +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Aspect +@Component +@Slf4j +public class LoggingAspect { + private Integer numDemande; + + @Around("execution(* fr.abes.item.traitement.*.*(..))") + public Object logMethodProcess(ProceedingJoinPoint joinPoint) throws Throwable { + String methodName = joinPoint.getSignature().getName(); + String className = joinPoint.getTarget().getClass().getName(); + Object[] args = joinPoint.getArgs(); + + // log.info("Entering method {} in class {} ", methodName, className); + //log.info("Methods arguments : {}", Arrays.toString(args)); + + if (className.equals("ProxyRetry") && methodName.equals("saveExemplaire")) { + joinPoint.getThis(); + } + Object result = joinPoint.proceed(); + log.info("resultat {}", result); + return result; + } +}