Skip to content

Commit

Permalink
Merge pull request #305 from linglong67/feature/modify-log-aspect
Browse files Browse the repository at this point in the history
[feat] log aop 내용 추가
  • Loading branch information
linglong67 authored Mar 15, 2024
2 parents 6e55dad + 8f3c396 commit 770223c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions module-api/src/main/java/com/kernel360/global/aop/LogAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Slf4j
Expand All @@ -21,4 +23,21 @@ public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {

return proceed;
}

@Pointcut("within(*..*Controller)")
public void controller() {}

@Around("controller()")
public Object logApiExecTime(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
Object proceed = joinPoint.proceed();

long executionTime = System.currentTimeMillis() - start;
Signature signature = joinPoint.getSignature();

log.info(String.format("##### @API Execution Time ##### [%dms] → %s.%s",
executionTime, signature.getDeclaringTypeName(), signature.getName()));

return proceed;
}
}

0 comments on commit 770223c

Please sign in to comment.