Commit adcaf76f authored by yanzg's avatar yanzg

常规BUG的修改

parent d9acfbef
...@@ -129,11 +129,13 @@ public class BaseRequestAspect implements ThreadNext.Next { ...@@ -129,11 +129,13 @@ public class BaseRequestAspect implements ThreadNext.Next {
* @param joinPoint * @param joinPoint
* @return * @return
*/ */
protected long requestLog(String tag, ProceedingJoinPoint joinPoint) { protected long requestLog(boolean clear, 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.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) {
...@@ -151,7 +153,7 @@ public class BaseRequestAspect implements ThreadNext.Next { ...@@ -151,7 +153,7 @@ public class BaseRequestAspect implements ThreadNext.Next {
* @param resultEx * @param resultEx
* @param start * @param start
*/ */
protected void responseLog(String tag, String url, ProceedingJoinPoint joinPoint, long start, Object result, Exception resultEx) { protected void responseLog(boolean clear, String tag, String url, ProceedingJoinPoint joinPoint, long start, Object result, Exception resultEx) {
try { try {
String name = joinPoint.getSignature().getName(); String name = joinPoint.getSignature().getName();
if (StringHelper.isEmpty(url)) { if (StringHelper.isEmpty(url)) {
...@@ -194,9 +196,11 @@ public class BaseRequestAspect implements ThreadNext.Next { ...@@ -194,9 +196,11 @@ public class BaseRequestAspect implements ThreadNext.Next {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (clear) {
Log.threadCommit(); Log.threadCommit();
} }
} }
}
/** /**
* 是否属于日志服务 * 是否属于日志服务
......
...@@ -37,7 +37,7 @@ public class FeignAspect extends BaseRequestAspect { ...@@ -37,7 +37,7 @@ 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(TAG, joinPoint); long start = requestLog(false, TAG, joinPoint);
Object result = null; Object result = null;
Exception ex = null; Exception ex = null;
...@@ -61,7 +61,7 @@ public class FeignAspect extends BaseRequestAspect { ...@@ -61,7 +61,7 @@ public class FeignAspect extends BaseRequestAspect {
ex = e; ex = e;
throw e; throw e;
} finally { } finally {
responseLog(TAG, StringHelper.EMPTY, joinPoint, start, result, ex); responseLog(false, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
} }
} }
......
...@@ -35,7 +35,7 @@ public class MqAspect extends BaseRequestAspect { ...@@ -35,7 +35,7 @@ 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(TAG, joinPoint); long start = requestLog(true, TAG, joinPoint);
Object result = null; Object result = null;
Exception ex = null; Exception ex = null;
try { try {
...@@ -47,7 +47,7 @@ public class MqAspect extends BaseRequestAspect { ...@@ -47,7 +47,7 @@ public class MqAspect extends BaseRequestAspect {
ex = e; ex = e;
throw e; throw e;
} finally { } finally {
responseLog(TAG, StringHelper.EMPTY, joinPoint, start, result, ex); responseLog(true, TAG, StringHelper.EMPTY, joinPoint, start, result, ex);
} }
} }
......
...@@ -58,7 +58,7 @@ public class WebAspect extends BaseRequestAspect { ...@@ -58,7 +58,7 @@ 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 {
// 用户数据库记录 // 用户数据库记录
long start = requestLog(TAG, joinPoint); long start = requestLog(true, 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 +84,7 @@ public class WebAspect extends BaseRequestAspect { ...@@ -84,7 +84,7 @@ public class WebAspect extends BaseRequestAspect {
if (!isGateWay) { if (!isGateWay) {
tokenFinish(flag); tokenFinish(flag);
} }
responseLog(TAG, HttpAspectUtil.getHttpRequestUrl(), joinPoint, start, result, ex); responseLog(true, 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