update 优化魔法值

This commit is contained in:
zendwang
2022-07-04 11:30:43 +08:00
parent b9931cda30
commit 686068c8ed
6 changed files with 13 additions and 10 deletions

View File

@ -28,11 +28,13 @@ import java.util.Map;
@Slf4j
public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor {
public static final String PROD_PROFILE = "prod";
private final TransmittableThreadLocal<StopWatch> invokeTimeTL = new TransmittableThreadLocal<>();
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!"prod".equals(SpringUtils.getActiveProfile())) {
if (!PROD_PROFILE.equals(SpringUtils.getActiveProfile())) {
String url = request.getMethod() + " " + request.getRequestURI();
// 打印请求参数
@ -67,7 +69,7 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
if (!"prod".equals(SpringUtils.getActiveProfile())) {
if (!PROD_PROFILE.equals(SpringUtils.getActiveProfile())) {
StopWatch stopWatch = invokeTimeTL.get();
stopWatch.stop();
log.debug("[PLUS]结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime());