huangxz
2026-03-02 8c350025ce5faf24a5544df106ab20363f566c87
feat: 注释掉LocalMockConfig中的Feign调用日志记录功能
1个文件已修改
104 ■■■■■ 已修改文件
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/LocalMockConfig.java 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/config/LocalMockConfig.java
@@ -1,57 +1,57 @@
package com.xiaopeng.automaticPilot.config;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import java.util.Arrays;
@Slf4j
@Aspect
@Configuration
//@Profile("local")
public class LocalMockConfig {
//    // ---- mock: getSecretById 远程不可用时返回本地 secret ----
//package com.xiaopeng.automaticPilot.config;
//
//    @Around("execution(* com.xiaopeng.unifiedverification.service.AuthBizServiceForSdk.getSecretById(..))")
//    public Object mockGetSecretById(ProceedingJoinPoint pjp) {
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Profile;
//
//import java.util.Arrays;
//
//@Slf4j
//@Aspect
//@Configuration
////@Profile("local")
//public class LocalMockConfig {
//
////    // ---- mock: getSecretById 远程不可用时返回本地 secret ----
////
////    @Around("execution(* com.xiaopeng.unifiedverification.service.AuthBizServiceForSdk.getSecretById(..))")
////    public Object mockGetSecretById(ProceedingJoinPoint pjp) {
////        try {
////            return pjp.proceed();
////        } catch (Throwable e) {
////            log.warn("[LocalMock] getSecretById 远程调用失败,返回本地 mock secret. error: {}", e.getMessage());
////            return "ghepbrwmgcispjja";
////        }
////    }
//
//    // ---- feign 调用全量日志 ----
//
//    @Around(
//        "within(@org.springframework.cloud.openfeign.FeignClient *)" +
//        " || within(com.xiaopeng.unifiedverification.remote.feign..*)"
//    )
//    public Object logFeignCall(ProceedingJoinPoint pjp) throws Throwable {
//        MethodSignature sig = (MethodSignature) pjp.getSignature();
//        String clazz  = sig.getDeclaringType().getSimpleName();
//        String method = sig.getName();
//        Object[] args = pjp.getArgs();
//
//        log.info("[FeignLog] >>> {}.{}() args={}", clazz, method, Arrays.toString(args));
//        long start = System.currentTimeMillis();
//        try {
//            return pjp.proceed();
//            Object result = pjp.proceed();
//            log.info("[FeignLog] <<< {}.{}() cost={}ms result={}", clazz, method,
//                    System.currentTimeMillis() - start, result);
//            return result;
//        } catch (Throwable e) {
//            log.warn("[LocalMock] getSecretById 远程调用失败,返回本地 mock secret. error: {}", e.getMessage());
//            return "ghepbrwmgcispjja";
//            log.error("[FeignLog] <<< {}.{}() cost={}ms EXCEPTION: {} - {}",
//                    clazz, method, System.currentTimeMillis() - start,
//                    e.getClass().getName(), e.getMessage());
//            throw e;
//        }
//    }
    // ---- feign 调用全量日志 ----
    @Around(
        "within(@org.springframework.cloud.openfeign.FeignClient *)" +
        " || within(com.xiaopeng.unifiedverification.remote.feign..*)"
    )
    public Object logFeignCall(ProceedingJoinPoint pjp) throws Throwable {
        MethodSignature sig = (MethodSignature) pjp.getSignature();
        String clazz  = sig.getDeclaringType().getSimpleName();
        String method = sig.getName();
        Object[] args = pjp.getArgs();
        log.info("[FeignLog] >>> {}.{}() args={}", clazz, method, Arrays.toString(args));
        long start = System.currentTimeMillis();
        try {
            Object result = pjp.proceed();
            log.info("[FeignLog] <<< {}.{}() cost={}ms result={}", clazz, method,
                    System.currentTimeMillis() - start, result);
            return result;
        } catch (Throwable e) {
            log.error("[FeignLog] <<< {}.{}() cost={}ms EXCEPTION: {} - {}",
                    clazz, method, System.currentTimeMillis() - start,
                    e.getClass().getName(), e.getMessage());
            throw e;
        }
    }
}
//}