use of com.whoiszxl.logger.entity.OptLogDTO in project shopzz by whoiszxl.
the class SSLogAspect method doAfterThrowable.
/**
* 异常通知
*
* @param e
*/
@AfterThrowing(pointcut = "ssLogAspect()", throwing = "e")
public void doAfterThrowable(Throwable e) {
tryCatch((aaa) -> {
OptLogDTO sysLog = get();
sysLog.setType("EX");
// 异常对象
sysLog.setExDetail(LogUtil.getStackTrace(e));
// 异常信息
sysLog.setExDesc(e.getMessage());
publishEvent(sysLog);
});
}
use of com.whoiszxl.logger.entity.OptLogDTO in project shopzz by whoiszxl.
the class SSLogAspect method recordLog.
@Before(value = "ssLogAspect()")
public void recordLog(JoinPoint joinPoint) throws Throwable {
tryCatch((val) -> {
// 开始时间
OptLogDTO sysLog = get();
sysLog.setCreateUser(BaseContextHandler.getUserId());
sysLog.setUserName(BaseContextHandler.getName());
String controllerDescription = "";
Api api = joinPoint.getTarget().getClass().getAnnotation(Api.class);
if (api != null) {
String[] tags = api.tags();
if (tags != null && tags.length > 0) {
controllerDescription = tags[0];
}
}
String controllerMethodDescription = LogUtil.getControllerMethodDescription(joinPoint);
if (StrUtil.isEmpty(controllerDescription)) {
sysLog.setDescription(controllerMethodDescription);
} else {
sysLog.setDescription(controllerDescription + "-" + controllerMethodDescription);
}
// 类名
sysLog.setClassPath(joinPoint.getTarget().getClass().getName());
// 获取执行的方法名
sysLog.setActionMethod(joinPoint.getSignature().getName());
// 参数
Object[] args = joinPoint.getArgs();
String strArgs = "";
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
try {
if (!request.getContentType().contains("multipart/form-data")) {
strArgs = JsonUtil.toJson(args);
}
} catch (Exception e) {
try {
strArgs = Arrays.toString(args);
} catch (Exception ex) {
log.warn("解析参数异常", ex);
}
}
sysLog.setParams(getText(strArgs));
if (request != null) {
sysLog.setRequestIp(ServletUtil.getClientIP(request));
sysLog.setRequestUri(URLUtil.getPath(request.getRequestURI()));
sysLog.setHttpMethod(request.getMethod());
sysLog.setUa(StrUtil.sub(request.getHeader("user-agent"), 0, 500));
}
sysLog.setStartTime(LocalDateTime.now());
THREAD_LOCAL.set(sysLog);
});
}
use of com.whoiszxl.logger.entity.OptLogDTO in project shopzz by whoiszxl.
the class SSLogAspect method doAfterReturning.
/**
* 返回通知
*
* @param ret
* @throws Throwable
*/
@AfterReturning(returning = "ret", pointcut = "ssLogAspect()")
public void doAfterReturning(Object ret) {
tryCatch((aaa) -> {
ResponseResult r = Convert.convert(ResponseResult.class, ret);
OptLogDTO sysLog = get();
if (r == null) {
sysLog.setType("OPT");
} else {
if (r.isOk()) {
sysLog.setType("OPT");
} else {
sysLog.setType("EX");
sysLog.setExDetail(r.getMessage());
}
sysLog.setResult(getText(r.toString()));
}
publishEvent(sysLog);
});
}
use of com.whoiszxl.logger.entity.OptLogDTO in project shopzz by whoiszxl.
the class SysLogListener method saveSysLog.
@Async
@Order
@EventListener(SysLogEvent.class)
public void saveSysLog(SysLogEvent event) {
OptLogDTO optLog = (OptLogDTO) event.getSource();
consumer.accept(optLog);
}
Aggregations