Commit 88b98773 authored by yanzg's avatar yanzg

常规BUG的修改

parent adcaf76f
......@@ -123,19 +123,29 @@ public class BaseRequestAspect implements ThreadNext.Next {
return paraJson;
}
/**
* 获取是否清空日志的标签
*
* @return 返回日志是否清空
*/
protected boolean requestLogInit() {
boolean clear = Log.threadCurrent() == null;
if (clear) {
Log.threadBegin();
}
return clear;
}
/**
* 记录请求日志
*
* @param joinPoint
* @return
*/
protected long requestLog(boolean clear, String tag, ProceedingJoinPoint joinPoint) {
protected long requestLog(String tag, ProceedingJoinPoint joinPoint) {
long start = System.currentTimeMillis();
try {
String name = joinPoint.getSignature().getName();
if (clear) {
Log.threadBegin();
}
Log.info(joinPoint.getSignature().getDeclaringType(), " %s [ %s ] request: %s",
tag, name, this.getMaxString(JsonHelper.serialize(joinPoint.getArgs())));
} catch (Exception ex) {
......
......@@ -37,7 +37,8 @@ public class FeignAspect extends BaseRequestAspect {
*/
@Around(value = "feignAspect()")
public Object requestFeignAround(ProceedingJoinPoint joinPoint) throws Throwable {
long start = requestLog(false, TAG, joinPoint);
boolean clear = requestLogInit();
long start = requestLog(TAG, joinPoint);
Object result = null;
Exception ex = null;
......@@ -61,7 +62,7 @@ public class FeignAspect extends BaseRequestAspect {
ex = e;
throw e;
} finally {
responseLog(false, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
responseLog(clear, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
}
}
......
......@@ -35,7 +35,8 @@ public class MqAspect extends BaseRequestAspect {
*/
@Around(value = "mqAspect()")
public Object requestWebAround(ProceedingJoinPoint joinPoint) throws Throwable {
long start = requestLog(true, TAG, joinPoint);
boolean clear = requestLogInit();
long start = requestLog(TAG, joinPoint);
Object result = null;
Exception ex = null;
try {
......@@ -47,7 +48,7 @@ public class MqAspect extends BaseRequestAspect {
ex = e;
throw e;
} finally {
responseLog(true, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
responseLog(clear, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
}
}
......
......@@ -57,8 +57,9 @@ public class WebAspect extends BaseRequestAspect {
*/
@Around(value = "webAspect()")
public Object requestWebAround(ProceedingJoinPoint joinPoint) throws Throwable {
boolean clear = requestLogInit();
// 用户数据库记录
long start = requestLog(true, TAG, joinPoint);
long start = requestLog(TAG, joinPoint);
Object result = null;
Exception ex = null;
Ref<Boolean> flag = new Ref<>(false);
......@@ -84,7 +85,7 @@ public class WebAspect extends BaseRequestAspect {
if (!isGateWay) {
tokenFinish(flag);
}
responseLog(true, TAG, HttpAspectUtil.getHttpRequestUrl(), joinPoint, start, result, ex);
responseLog(clear, TAG, HttpAspectUtil.getHttpRequestUrl(), joinPoint, start, result, ex);
}
}
......
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