Commit d0cb8c27 authored by yanzg's avatar yanzg

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

parent f8f13ba4
......@@ -21,10 +21,10 @@ public class UrlHelper {
*/
public static String encoding(String from, String encoding) {
try {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < from.length(); i++) {
char c = from.charAt(i);
if (c >= 0 && c <= 255) {
if (c <= 255) {
sb.append(c);
} else {
String t = URLEncoder.encode("" + c, encoding);
......
......@@ -7,6 +7,7 @@ import com.yanzuoguang.token.TokenHelper;
import com.yanzuoguang.util.exception.ExceptionHelper;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.TypeHelper;
import com.yanzuoguang.util.helper.UrlHelper;
import com.yanzuoguang.util.log.Log;
import com.yanzuoguang.util.vo.CloudConfig;
import com.yanzuoguang.util.vo.ResponseResult;
......@@ -90,7 +91,7 @@ public class AspectWeb {
}
Object requestBody = aspectLogBody.getRequestBody(joinPoint);
boolean clear = aspectLog.requestLogInit();
LogInfoVo log = aspectLog.start(declaringType, TAG, url, requestBody, clear);
LogInfoVo log = aspectLog.start(declaringType, TAG, UrlHelper.getPage(url), String.format("请求地址:%s 请求内容:%s", url, requestBody), clear);
Exception ex = null;
boolean isInit = false;
......
......@@ -65,15 +65,8 @@ public class LogCountTime implements ThreadNext.Next, InitializingBean {
private LogUrlCountVo getCount(String tag, String urlFrom, int level) {
// 初始化日期
initToday();
// 目标地址
String urlTo;
if (urlFrom.contains(URL_PARA_START)) {
urlTo = urlFrom.substring(0, urlFrom.indexOf(URL_PARA_START));
} else {
urlTo = urlFrom;
}
// 关键字
String key = StringHelper.getId(tag, urlTo, level);
String key = StringHelper.getId(tag, urlFrom, level);
// 缓存中获取对象
LogUrlCountVo ret = todayMemoryCache.get(key);
if (ret != null) {
......@@ -85,7 +78,7 @@ public class LogCountTime implements ThreadNext.Next, InitializingBean {
if (ret != null) {
return ret;
}
ret = new LogUrlCountVo(tag, urlTo, level);
ret = new LogUrlCountVo(tag, urlFrom, level);
todayMemoryCache.put(key, ret);
return ret;
}
......
......@@ -2,6 +2,7 @@ package com.yanzuoguang.log;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.helper.UrlHelper;
import com.yanzuoguang.util.thread.ThreadNext;
import com.yanzuoguang.util.vo.CloudConfig;
import org.springframework.beans.factory.InitializingBean;
......@@ -78,6 +79,8 @@ public class LogLocal implements ThreadNext.Next, InitializingBean {
} else {
useTime = log.getUseTime();
}
// 修复当前地址
log.setUrl(UrlHelper.getPage(log.getUrl()));
// 获取当前请求的级别
int level = 0;
......
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