Commit 88b98773 authored by yanzg's avatar yanzg

常规BUG的修改

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