|
@@ -1,6 +1,7 @@
|
|
|
package com.tzld.piaoquan.ad.engine.server.controller;
|
|
|
|
|
|
import com.google.common.base.Stopwatch;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.util.JSONUtils;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.util.TraceUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -12,6 +13,7 @@ import org.aspectj.lang.annotation.Pointcut;
|
|
|
import org.aspectj.lang.reflect.MethodSignature;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
@@ -23,12 +25,12 @@ import java.util.concurrent.TimeUnit;
|
|
|
public class ControllerAspect {
|
|
|
|
|
|
@Pointcut("execution(* com.tzld.piaoquan.ad.engine.server.controller.*Controller.*(..))")
|
|
|
- public void logPointcut(){
|
|
|
+ public void logPointcut() {
|
|
|
|
|
|
}
|
|
|
|
|
|
@Pointcut("execution(* com.tzld.piaoquan.ad.engine.server.controller.HealthController.*(..))")
|
|
|
- public void excludePointcut(){
|
|
|
+ public void excludePointcut() {
|
|
|
|
|
|
}
|
|
|
|
|
@@ -39,13 +41,15 @@ public class ControllerAspect {
|
|
|
String className = pjp.getTarget().getClass().getSimpleName();
|
|
|
MethodSignature signature = (MethodSignature) pjp.getSignature();
|
|
|
Stopwatch stopwatch = Stopwatch.createStarted();
|
|
|
- log.info("request className=[{}], method=[{}], param=[{}]", className, signature.getName(),
|
|
|
- JSONUtils.toJson(pjp.getArgs()));
|
|
|
+
|
|
|
+ String param = JSONUtils.toJson(pjp.getArgs(), Sets.newHashSet("statisticsLog"));
|
|
|
+
|
|
|
+ log.info("request className=[{}], method=[{}], param=[{}]", className, signature.getName(), param);
|
|
|
Object result = pjp.proceed();
|
|
|
if (result != null && result instanceof String) {
|
|
|
- log.info("request method=[{}] param=[{}] result=[{}] cost=[{}]", signature.getName(),JSONUtils.toJson(pjp.getArgs()),result, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
|
|
|
+ log.info("request method=[{}] param=[{}] result=[{}] cost=[{}]", signature.getName(), param, result, stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
|
|
|
} else {
|
|
|
- log.info("request method=[{}] param=[{}] result=[{}] cost=[{}]", signature.getName(),JSONUtils.toJson(pjp.getArgs()), JSONUtils.toJson(result), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
|
|
|
+ log.info("request method=[{}] param=[{}] result=[{}] cost=[{}]", signature.getName(), param, JSONUtils.toJson(result), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
|
|
|
}
|
|
|
TraceUtils.removeMDC();
|
|
|
return result;
|