Commit fb71a7fc authored by 于桐's avatar 于桐

调整日志打印,增加耗时区间

parent 6795c864
...@@ -55,13 +55,23 @@ public class LogCallHttpAspect { ...@@ -55,13 +55,23 @@ public class LogCallHttpAspect {
hasException = true; hasException = true;
throw e; throw e;
} finally { } finally {
Stopwatch stop = stopwatch.stop(); long elapsed = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
long elapsed = stop.elapsed(TimeUnit.MILLISECONDS);
String resultStr = result == null ? "" : objectMapper.writeValueAsString(result); String resultStr = result == null ? "" : objectMapper.writeValueAsString(result);
resultStr = resultStr.length() < 500 ? resultStr : resultStr.substring(0, 500); resultStr = resultStr.length() < 500 ? resultStr : resultStr.substring(0, 500);
log.info("[httpRequestLog],url:[{}],remoteIP:[{}],args:[{}],duration:[{}],exception:[{}],result:[{}]", log.info("[httpRequestLog],url:[{}],duration:[{}],[耗时区间]{},remoteIP:[{}],args:[{}],exception:[{}],result:[{}]",
request.getRequestURL(), remoteIP, args, elapsed, hasException, resultStr); request.getRequestURL(), elapsed, slowlyTag(elapsed), remoteIP, args, hasException, resultStr);
} }
return result; return result;
} }
private String slowlyTag(long elapsed) {
Long second = elapsed / 1000L;
String outTimeFormat = "[outTime_%s]";
StringBuffer sb = new StringBuffer();
// 3秒步长
for (int outTime = 3; outTime <= second; outTime ++) {
sb.append(String.format(outTimeFormat, outTime));
}
return sb.toString();
}
} }
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