Skip to content

Commit

Permalink
Feat : Ajout classe aspect pour intercepter les log
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-maraval committed Apr 19, 2024
1 parent ecd52c8 commit 4b2c704
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions batch/src/main/java/fr/abes/item/logging/LoggingAspect.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 4b2c704

Please sign in to comment.