Commit ea9648f1 authored by yanzg's avatar yanzg

不记录系统日志

parent 426d1092
...@@ -191,7 +191,7 @@ public class BaseRequestAspect { ...@@ -191,7 +191,7 @@ public class BaseRequestAspect {
protected void responseLog(LogVo log, String tag, boolean logFlag, ProceedingJoinPoint joinPoint, long start, Object result, Exception resultEx) { protected void responseLog(LogVo log, String tag, boolean logFlag, ProceedingJoinPoint joinPoint, long start, Object result, Exception resultEx) {
try { try {
long time = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
boolean isLog = (logFlag && logCommon) || resultEx != null; boolean isLog = (logFlag && logCommon && this.logLocal.isLog()) || resultEx != null;
String name = joinPoint.getSignature().getName(); String name = joinPoint.getSignature().getName();
// 处理结果 // 处理结果
ResponseResult responseResult = responseDefault; ResponseResult responseResult = responseDefault;
......
...@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop; ...@@ -3,6 +3,7 @@ package com.yanzuoguang.cloud.aop;
import com.yanzuoguang.util.contants.ResultConstants; import com.yanzuoguang.util.contants.ResultConstants;
import com.yanzuoguang.util.exception.CodeException; import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.exception.ExceptionHelper; import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.LogVo; import com.yanzuoguang.util.vo.LogVo;
import com.yanzuoguang.util.vo.ResponseResult; import com.yanzuoguang.util.vo.ResponseResult;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
...@@ -37,9 +38,17 @@ public class FeignAspect extends BaseRequestAspect { ...@@ -37,9 +38,17 @@ public class FeignAspect extends BaseRequestAspect {
*/ */
@Around(value = "feignAspect()") @Around(value = "feignAspect()")
public Object requestFeignAround(ProceedingJoinPoint joinPoint) throws Throwable { public Object requestFeignAround(ProceedingJoinPoint joinPoint) throws Throwable {
LogVo log = null;
boolean clear = requestLogInit(); boolean clear = requestLogInit();
long start = requestLog(TAG, clear, joinPoint); long start = System.currentTimeMillis();
LogVo log = startLog(TAG, getMethodUrl(joinPoint), getRequestBody(joinPoint)); if (clear) {
log = startLog(TAG, getMethodUrl(joinPoint), getRequestBody(joinPoint));
clear = clear && log != null;
}
if (clear) {
Log.threadBegin();
start = requestLog(TAG, clear, joinPoint);
}
Object result = null; Object result = null;
Exception ex = null; Exception ex = null;
......
...@@ -167,7 +167,7 @@ public class LogLocal implements ThreadNext.Next, InitializingBean { ...@@ -167,7 +167,7 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
* @param keys * @param keys
* @return * @return
*/ */
private boolean isLog(String... keys) { public boolean isLog(String... keys) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(this.applicationName); list.add(this.applicationName);
for (String item : keys) { for (String item : keys) {
......
...@@ -45,10 +45,13 @@ public class MqAspect extends BaseRequestAspect { ...@@ -45,10 +45,13 @@ public class MqAspect extends BaseRequestAspect {
boolean clear = isRabbit(joinPoint); boolean clear = isRabbit(joinPoint);
LogVo log = null; LogVo log = null;
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
if (clear) {
log = startLog(TAG, getMethodUrl(joinPoint), getRequestBody(joinPoint));
clear = clear && log != null;
}
if (clear) { if (clear) {
Log.threadBegin(); Log.threadBegin();
start = requestLog(TAG, clear, joinPoint); start = requestLog(TAG, clear, joinPoint);
log = startLog(TAG, getMethodUrl(joinPoint), getRequestBody(joinPoint));
} }
Object result = null; Object result = null;
Exception ex = null; Exception ex = null;
......
...@@ -70,10 +70,18 @@ public class WebAspect extends BaseRequestAspect { ...@@ -70,10 +70,18 @@ public class WebAspect extends BaseRequestAspect {
result = executeMethod(joinPoint); result = executeMethod(joinPoint);
return result; return result;
} }
LogVo log = null;
boolean clear = requestLogInit(); boolean clear = requestLogInit();
// 用户数据库记录 long start = System.currentTimeMillis();
long start = requestLog(TAG, clear, joinPoint); if (clear) {
LogVo log = startLog(TAG, HttpAspectUtil.getHttpRequestUrl(), getRequestBody(joinPoint)); log = startLog(TAG, getMethodUrl(joinPoint), getRequestBody(joinPoint));
clear = clear && log != null;
}
if (clear) {
Log.threadBegin();
start = requestLog(TAG, clear, joinPoint);
}
Exception ex = null; Exception ex = null;
boolean isInit = false; boolean isInit = false;
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment