Commit bd200ded authored by 赵啸非's avatar 赵啸非

添加前端页面

parent d9389226
package com.mortals.xhx.base.framework.aspect; package com.mortals.xhx.base.framework.aspect;
import cn.hutool.core.net.Ipv4Util;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -61,17 +64,17 @@ public class WebLogAspect { ...@@ -61,17 +64,17 @@ public class WebLogAspect {
public void afterReturning(Object result) { public void afterReturning(Object result) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
Map<String, String> map = MDC.getCopyOfContextMap(); Map<String, String> map = MDC.getCopyOfContextMap();
if (map != null&&result!=null) { if (map != null&&result!=null) {
String startTime = map.getOrDefault("startTime", String.valueOf(System.currentTimeMillis())); String startTime = map.getOrDefault("startTime", String.valueOf(System.currentTimeMillis()));
long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime)); long takeTime = (System.currentTimeMillis() - Long.parseLong(startTime));
if (result instanceof String) { if (result instanceof String) {
log.info(" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}" log.info(" \n 请求路径:{} 耗时:{}ms 客户端IP:{} \n 请求报文:{} \n 响应报文:{} "
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), result); , request.getRequestURI(), takeTime,ServletUtil.getClientIP(request), map.getOrDefault("req", ""), result);
} else { } else {
log.info(" \n 请求路径:{} 耗时:{}ms 客户端IP:{}\n 请求报文:{} \n 响应报文:{}"
log.info(" \n 请求路径:{} 耗时:{}ms \n 请求报文:{} \n 响应报文:{}" , request.getRequestURI(), takeTime,ServletUtil.getClientIP(request), map.getOrDefault("req", ""), JSON.toJSONString(result));
, request.getRequestURI(), takeTime, map.getOrDefault("req", ""), JSON.toJSONString(result));
} }
} }
......
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