|
|
@ -50,10 +50,12 @@ public class LogAspect { |
|
|
|
Object result; |
|
|
|
currentTime.set(System.currentTimeMillis()); |
|
|
|
result = joinPoint.proceed(); |
|
|
|
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get()); |
|
|
|
Log log = new Log("INFO", System.currentTimeMillis() - currentTime.get()); |
|
|
|
currentTime.remove(); |
|
|
|
HttpServletRequest request = RequestHolder.getHttpServletRequest(); |
|
|
|
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log); |
|
|
|
//获取端口号 |
|
|
|
log.setPort(StringUtils.getPort(request)); |
|
|
|
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), joinPoint, log); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -61,21 +63,21 @@ public class LogAspect { |
|
|
|
* 配置异常通知 |
|
|
|
* |
|
|
|
* @param joinPoint join point for advice |
|
|
|
* @param e exception |
|
|
|
* @param e exception |
|
|
|
*/ |
|
|
|
@AfterThrowing(pointcut = "logPointcut()", throwing = "e") |
|
|
|
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) { |
|
|
|
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime.get()); |
|
|
|
Log log = new Log("ERROR", System.currentTimeMillis() - currentTime.get()); |
|
|
|
currentTime.remove(); |
|
|
|
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes()); |
|
|
|
HttpServletRequest request = RequestHolder.getHttpServletRequest(); |
|
|
|
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log); |
|
|
|
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log); |
|
|
|
} |
|
|
|
|
|
|
|
public String getUsername() { |
|
|
|
try { |
|
|
|
return SecurityUtils.getCurrentUsername(); |
|
|
|
}catch (Exception e){ |
|
|
|
} catch (Exception e) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|