Skip to content

Commit

Permalink
mod: 打印异常参数(route)
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrunkang committed Feb 7, 2023
1 parent f38ef6e commit 8084aae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
}
ccResponse.setData(proceedingJoinPoint.proceed());
} catch (Throwable throwable) {
log.error(requestUrl + " 异常,打印发生移除的参数: {}", JsonUtils.toJsonStr(proceedingJoinPoint.getArgs()));
log.error("[API] " + requestUrl + " 异常,打印发生移除的参数: {}", JsonUtils.toJsonStr(proceedingJoinPoint.getArgs()));
throwable.printStackTrace();
if (throwable instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.upupor.framework.CcConstant;
import com.upupor.framework.ErrorCode;
import com.upupor.framework.utils.CcUtils;
import com.upupor.framework.utils.JsonUtils;
import com.upupor.service.listener.event.BuriedPointDataEvent;
import com.upupor.web.aspects.service.checker.page.PageAspectChecker;
import com.upupor.web.aspects.service.checker.page.dto.PageCheckDto;
Expand Down Expand Up @@ -95,7 +96,7 @@ public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
assert attributes != null;
HttpServletRequest request = attributes.getRequest();

String requestUrl = request.getRequestURL().toString();
// 页面请求埋点
BuriedPointDataEvent pointEvent = BuriedPointDataEvent.builder().request(request).pointType(PointType.PAGE_REQUEST).build();
publisher.publishEvent(pointEvent);
Expand Down Expand Up @@ -125,11 +126,12 @@ public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable

} catch (Exception exception) {
exception.printStackTrace();
log.error("[Route] " + requestUrl + " 异常,打印发生移除的参数: {}", JsonUtils.toJsonStr(proceedingJoinPoint.getArgs()));
return exceptionView(CcUtils.stop(stopWatch), servletPath, exception);
}

// 执行业务后
String format = String.format("URL:%s \nconsume time:%s ms", request.getRequestURL().toString(), CcUtils.stop(stopWatch));
String format = String.format("URL:%s \nconsume time:%s ms", requestUrl, CcUtils.stop(stopWatch));
// 日志打印
log.info(format);

Expand Down

0 comments on commit 8084aae

Please sign in to comment.