日志修改
This commit is contained in:
parent
ee1e10b237
commit
7c4b4f12ee
@ -6,7 +6,6 @@ import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||
import org.apache.ibatis.logging.Log;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class StdOutImplCustom implements Log {
|
||||
|
||||
@ -18,7 +17,7 @@ public class StdOutImplCustom implements Log {
|
||||
if (!Objects.equals(TaskAspect.onlyPrintInterface, 1)) {
|
||||
return true;
|
||||
}
|
||||
return Optional.ofNullable(ThreadLocalUtil.getByKey(Cts.IF_FROM_TASK_KEY, Boolean.class)).map(b -> !b).orElse(true);
|
||||
return Objects.equals(ThreadLocalUtil.getByKey(Cts.TL_IS_FROM_WEB, Boolean.class), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
package com.zhgd.interceptor;
|
||||
|
||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@Slf4j
|
||||
public class ThreadLocalInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
ThreadLocalUtil.remove();
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@ package com.zhgd.xmgl.config;
|
||||
|
||||
import com.license.entity.dto.LicenseCheckInterceptor;
|
||||
import com.zhgd.interceptor.LogInterceptor;
|
||||
import com.zhgd.interceptor.ThreadLocalInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
@ -51,7 +50,6 @@ class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new LogInterceptor()).addPathPatterns("/**");
|
||||
registry.addInterceptor(new ThreadLocalInterceptor()).addPathPatterns("/**");
|
||||
registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns("/xmgl/base/login");
|
||||
registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns("/account/user/login");
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class TaskAspect {
|
||||
|
||||
if (null == context) {
|
||||
RequestIdUtil.setRequestId("-t"); //主线程没有MDC就自己生成一个
|
||||
ThreadLocalUtil.addInKey(Cts.IF_FROM_TASK_KEY, true);
|
||||
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_TASK, true);
|
||||
log.info("task方法开始:{}", methodName);
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ public interface Cts {
|
||||
String TL_XZ_HIKVISION_COMPARE_DATA_RETRY = "tl_xz_hikvision_compare_data";
|
||||
String TYPE = "type";
|
||||
String TEAM_ID = "teamId";
|
||||
String IF_FROM_TASK_KEY = "ifFromTaskKey";
|
||||
String TL_IS_FROM_TASK = "isFromTask";
|
||||
String DEPARTMENT_ID = "departmentId";
|
||||
String RESERVATION_TYPE = "reservationType";
|
||||
String TL_IS_FROM_WEB = "isFromWeb";
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package com.zhgd.xmgl.security;
|
||||
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.util.RequestIdUtil;
|
||||
import com.zhgd.xmgl.util.ThreadLocalUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -14,12 +16,14 @@ public class RequestIdFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
RequestIdUtil.setRequestId("-i");
|
||||
ThreadLocalUtil.addInKey(Cts.TL_IS_FROM_WEB, true);
|
||||
log.info("接口开始...");
|
||||
try {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} finally {
|
||||
log.info("接口结束...");
|
||||
RequestIdUtil.clear();
|
||||
ThreadLocalUtil.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,8 +10,8 @@ public class ThreadLocalUtil {
|
||||
|
||||
}
|
||||
|
||||
public static void set(JSONObject str) {
|
||||
threadLocal.set(str);
|
||||
public static void set(JSONObject object) {
|
||||
threadLocal.set(object);
|
||||
}
|
||||
|
||||
public static JSONObject get() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user