Commit 77fb7cbb authored by yanzg's avatar yanzg

修复异常提醒,从而正确的跟踪异常信息

parent 899c303a
......@@ -41,11 +41,6 @@ public class AspectLogResult {
return;
}
try {
ResponseResult<?> responseResult = getJson(resultFrom, resultEx);
String json = JsonHelper.serialize(responseResult);
String result = logString.getMaxString(json);
log.setResult(result);
log.setEnd(System.currentTimeMillis());
long useTime = log.getEnd() - log.getStart();
log.setUseTime((int) useTime);
......@@ -54,8 +49,12 @@ public class AspectLogResult {
} else {
log.setStatus(LogInfoVo.STATUS_OK);
}
// 输出请求结果
logLocal.result(log);
ResponseResult<?> responseResult = getJson(resultFrom, resultEx);
String json = JsonHelper.serialize(responseResult);
String result = logString.getMaxString(json);
log.setResult(result);
// 输出日志标记
boolean isLogCommon = log.isLogFlag() && this.cloudConfig.isLogCommon();
boolean isError = resultEx != null;
......@@ -66,7 +65,9 @@ public class AspectLogResult {
} catch (Exception e) {
ExceptionHelper.PrintError(AspectLogResult.class, e);
} finally {
logLocal.remove(log);
// 输出请求结果
logLocal.result(log);
if (log.isLogFlag()) {
Log.threadCommit();
}
......
......@@ -48,7 +48,6 @@ public class LogCountTime {
}
}
}
}
/**
......
......@@ -40,10 +40,11 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
*/
protected volatile MemoryCache<Timeout<LogInfoVo>> cache = new MemoryCache<>(CLEAR_CACHE);
public LogLocal(LogBase logBase, CloudConfig cloudConfig, List<LogFilter> logFilters) {
public LogLocal(LogBase logBase, CloudConfig cloudConfig, List<LogFilter> logFilters, LogCountTime logCountTime) {
this.logBase = logBase;
this.cloudConfig = cloudConfig;
this.logFilters = logFilters;
this.logCountTime = logCountTime;
}
@Override
......@@ -73,12 +74,7 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
}
// 日志请求不记录,防止死循环递归
boolean isLog = isLog(log.getTag(), log.getUrl());
if (isLog) {
this.remove(log);
} else {
this.resultWrite(log);
}
this.resultWrite(log);
String fullUrl = String.format("%s:%s", tag, url);
logCountTime.start(fullUrl);
......@@ -89,14 +85,6 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
long time = System.currentTimeMillis() - log.getStart();
// 记录请求时间
logCountTime.finish(fullUrl, time, isError);
}
/**
* 写入状态
*
* @param log 日志对象
*/
private void resultWrite(LogInfoVo log) {
if (log == null || StringHelper.isEmpty(log.getLogId())) {
return;
}
......@@ -114,14 +102,6 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
}
}
/**
* 删除请求信息
*
* @param log 删除日志
*/
public void remove(LogInfoVo log) {
this.resultWrite(log, StringHelper.EMPTY, StringHelper.EMPTY, false);
}
/**
* 是否属于日志服务
......@@ -160,7 +140,7 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
}
// 判断是否达到超时时间
if (timeout.isMaxTime(this.cloudConfig.getLogTimeMax(), this.cloudConfig.getLogTimeSplit())) {
this.resultWrite(timeout.getData(), MAX_TIME, MAX_TIME_NAME, true);
this.result(timeout.getData());
}
}
return true;
......
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