|
|
@ -1,36 +1,32 @@
|
|
|
|
package cokr.xit.ens.core.aop;
|
|
|
|
package cokr.xit.ens.core.aop;
|
|
|
|
|
|
|
|
|
|
|
|
import cokr.xit.ens.core.aop.repository.AccessLogRepository;
|
|
|
|
import java.io.*;
|
|
|
|
import cokr.xit.ens.core.exception.EnsException;
|
|
|
|
import java.util.*;
|
|
|
|
import cokr.xit.ens.core.exception.code.EnsErrCd;
|
|
|
|
import java.util.regex.*;
|
|
|
|
import cokr.xit.ens.core.monitor.slack.event.MonitorEvent;
|
|
|
|
import java.util.stream.*;
|
|
|
|
import cokr.xit.ens.core.utils.CmmnUtil;
|
|
|
|
|
|
|
|
import cokr.xit.ens.core.utils.JwtUtil;
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import org.aspectj.lang.*;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import org.aspectj.lang.annotation.*;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
|
|
|
|
|
import org.aspectj.lang.annotation.Around;
|
|
|
|
|
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
|
|
|
|
|
import org.aspectj.lang.annotation.Pointcut;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.*;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.context.*;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.*;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.*;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
import org.springframework.util.*;
|
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
|
import org.springframework.web.context.request.*;
|
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.*;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import com.fasterxml.jackson.databind.*;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import cokr.xit.ens.core.aop.repository.*;
|
|
|
|
import java.util.List;
|
|
|
|
import cokr.xit.ens.core.exception.*;
|
|
|
|
import java.util.Map;
|
|
|
|
import cokr.xit.ens.core.exception.code.*;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import cokr.xit.ens.core.monitor.slack.event.*;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import cokr.xit.ens.core.utils.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import lombok.*;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author (주)엑스아이티 개발팀
|
|
|
|
* @author (주)엑스아이티 개발팀
|
|
|
@ -59,6 +55,12 @@ public class AccessLogAspect {
|
|
|
|
@Value("${app.access.auth.exclude.uri}")
|
|
|
|
@Value("${app.access.auth.exclude.uri}")
|
|
|
|
private List<String> EXCLUDE_URIS;
|
|
|
|
private List<String> EXCLUDE_URIS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${app.jpa.logging.param:false}")
|
|
|
|
|
|
|
|
private boolean JPA_LOGGING_PARAM;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${app.jpa.logging.result:false}")
|
|
|
|
|
|
|
|
private boolean JPA_LOGGING_RESULT;
|
|
|
|
|
|
|
|
|
|
|
|
@Pointcut("execution(* cokr.xit..presentation.*Controller.*(..))")
|
|
|
|
@Pointcut("execution(* cokr.xit..presentation.*Controller.*(..))")
|
|
|
|
public void presentationLayer() {
|
|
|
|
public void presentationLayer() {
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -368,5 +370,26 @@ public class AccessLogAspect {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: JPA 쿼리 로그 출력 코드 추가
|
|
|
|
|
|
|
|
@ConditionalOnProperty(value = "app.jpa.logging.enabled", havingValue = "true", matchIfMissing = false)
|
|
|
|
|
|
|
|
@Around("execution(* org.springframework.data.repository.CrudRepository+.*(..))")
|
|
|
|
|
|
|
|
public Object logJpaQuery(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
|
|
|
|
|
|
String methodName = joinPoint.getSignature().getDeclaringType().getSimpleName() + "." + joinPoint.getSignature().getName();
|
|
|
|
|
|
|
|
Object[] args = joinPoint.getArgs();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(JPA_LOGGING_PARAM)
|
|
|
|
|
|
|
|
log.info("Executing JPA query - {}\n args: {}", methodName, Arrays.toString(args));
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log.info("Executing JPA query - {}", methodName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
Object result = joinPoint.proceed();
|
|
|
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(JPA_LOGGING_RESULT)
|
|
|
|
|
|
|
|
log.info("JPA query - {} : executed in {} ms\n result: {}", methodName, (endTime - startTime), result);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
log.info("JPA query - {} : executed in {} ms", methodName, (endTime - startTime));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|