|
|
|
@ -10,7 +10,7 @@ import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.concurrent.Future;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import kr.xit.core.biz.model.LoggingDTO;
|
|
|
|
|
import kr.xit.core.biz.service.ILoggingService;
|
|
|
|
|
import kr.xit.core.biz.service.IApiLoggingService;
|
|
|
|
|
import kr.xit.core.exception.BizRuntimeException;
|
|
|
|
|
import kr.xit.core.model.ApiResponseDTO;
|
|
|
|
|
import kr.xit.core.spring.util.error.ErrorParse;
|
|
|
|
@ -85,12 +85,12 @@ public class TraceLoggerAspect {
|
|
|
|
|
@Value("#{'${app.log.mdc.exclude-patterns}'.split(',')}")
|
|
|
|
|
private String[] excludes;
|
|
|
|
|
|
|
|
|
|
private final ILoggingService loggingService;
|
|
|
|
|
private final IApiLoggingService apiLoggingService;
|
|
|
|
|
private final SlackWebhookPush slackWebhookPush;
|
|
|
|
|
private static final String REQUEST_TRACE_ID = "request_trace_id";
|
|
|
|
|
|
|
|
|
|
public TraceLoggerAspect(@Lazy ILoggingService loggingService, SlackWebhookPush slackWebhookPush) {
|
|
|
|
|
this.loggingService = loggingService;
|
|
|
|
|
public TraceLoggerAspect(@Lazy IApiLoggingService apiLoggingService, SlackWebhookPush slackWebhookPush) {
|
|
|
|
|
this.apiLoggingService = apiLoggingService;
|
|
|
|
|
this.slackWebhookPush = slackWebhookPush;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -122,7 +122,7 @@ public class TraceLoggerAspect {
|
|
|
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
|
|
|
|
|
HttpServletRequest request = attributes != null? attributes.getRequest(): null;
|
|
|
|
|
|
|
|
|
|
traceLogging(JsonUtils.toObjByObj(pjp.getArgs()[0], JSONObject.class), request);
|
|
|
|
|
traceApiLogging(JsonUtils.toObjByObj(pjp.getArgs()[0], JSONObject.class), request);
|
|
|
|
|
Object result = pjp.proceed();
|
|
|
|
|
|
|
|
|
|
//noinspection rawtypes
|
|
|
|
@ -131,9 +131,9 @@ public class TraceLoggerAspect {
|
|
|
|
|
while(true) {
|
|
|
|
|
if (future.isDone()) break;
|
|
|
|
|
}
|
|
|
|
|
traceLoggingResult(future.get());
|
|
|
|
|
traceApiLoggingResult(future.get());
|
|
|
|
|
}else{
|
|
|
|
|
traceLoggingResult(result);
|
|
|
|
|
traceApiLoggingResult(result);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
@ -151,7 +151,7 @@ public class TraceLoggerAspect {
|
|
|
|
|
|
|
|
|
|
@AfterThrowing(value = "errorPointCut()", throwing="error")
|
|
|
|
|
public void afterThrowingProceed(final JoinPoint jp, final Throwable error) {
|
|
|
|
|
traceLoggingError(jp, error);
|
|
|
|
|
traceApiLoggingError(jp, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -159,7 +159,7 @@ public class TraceLoggerAspect {
|
|
|
|
|
* @param json JSONObject
|
|
|
|
|
* @param request HttpServletRequest
|
|
|
|
|
*/
|
|
|
|
|
protected void traceLogging(final JSONObject json, final HttpServletRequest request) {
|
|
|
|
|
protected void traceApiLogging(final JSONObject json, final HttpServletRequest request) {
|
|
|
|
|
String uri = "";
|
|
|
|
|
if(request != null) {
|
|
|
|
|
uri = request.getRequestURI();
|
|
|
|
@ -197,11 +197,11 @@ log.info("@@@@@@@@@@@@@@@@@로깅 start : [\n{}\n]",MDC.getCopyOfContextMap());
|
|
|
|
|
.accessToken("")
|
|
|
|
|
.sessionId(MDC.getCopyOfContextMap().get("sessionId"))
|
|
|
|
|
.build();
|
|
|
|
|
loggingService.saveLogging(loggingDTO);
|
|
|
|
|
apiLoggingService.saveApiLogging(loggingDTO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void traceLoggingResult(final Object result) {
|
|
|
|
|
protected void traceApiLoggingResult(final Object result) {
|
|
|
|
|
String success = "true";
|
|
|
|
|
//FIXME: slack webhook log push
|
|
|
|
|
if(result instanceof ApiResponseDTO<?> apiResponseDTO){
|
|
|
|
@ -237,7 +237,7 @@ log.info("@@@@@@@@@@@@@@@@@로깅 start : [\n{}\n]",MDC.getCopyOfContextMap());
|
|
|
|
|
.message(HttpStatus.OK.name())
|
|
|
|
|
.build();
|
|
|
|
|
//}
|
|
|
|
|
loggingService.modifyLogging(reqDTO);
|
|
|
|
|
apiLoggingService.modifyApiLogging(reqDTO);
|
|
|
|
|
//loggingService.saveLogging(reqDTO);
|
|
|
|
|
|
|
|
|
|
log.info("@@@@@@@@@@@@@@로깅 end[\n{}\n]", MDC.getCopyOfContextMap());
|
|
|
|
@ -265,13 +265,14 @@ log.info("@@@@@@@@@@@@@@@@@로깅 start : [\n{}\n]",MDC.getCopyOfContextMap());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void traceLoggingError(final JoinPoint jp, final Throwable e) {
|
|
|
|
|
protected void traceApiLoggingError(final JoinPoint jp, final Throwable e) {
|
|
|
|
|
log.info("MDC request_trace_id :: {}", MDC.get(REQUEST_TRACE_ID));
|
|
|
|
|
if(Checks.isEmpty(MDC.get(REQUEST_TRACE_ID))) return;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
ApiResponseDTO dto = ErrorParse.extractError(e);
|
|
|
|
|
|
|
|
|
|
loggingService.modifyLogging(
|
|
|
|
|
apiLoggingService.modifyApiLogging(
|
|
|
|
|
LoggingDTO
|
|
|
|
|
.builder()
|
|
|
|
|
.requestId(MDC.get(REQUEST_TRACE_ID))
|
|
|
|
@ -378,6 +379,7 @@ log.info("@@@@@@@@@@@@@@@@@로깅 start : [\n{}\n]",MDC.getCopyOfContextMap());
|
|
|
|
|
PPLUS("POST-PLUS", "Post Plus", "/pplus/"),
|
|
|
|
|
NICE("NICE", "NICE CI", "/nice/"),
|
|
|
|
|
EPOST("EPOST", "E-POST", "/ag/"),
|
|
|
|
|
SISUL("SISUL", "시설공단", "/sisul/"),
|
|
|
|
|
BATCH("BATCH", "미정의", "/미정의/"),
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|