Commit 18a27186 authored by xiaoguang.xu's avatar xiaoguang.xu

fix : 提升logAspect使用体验...

parent 4590ca42
package cn.quantgroup.xyqb.aspect.logcaller;
import cn.quantgroup.xyqb.util.IPUtil;
import com.google.common.base.Stopwatch;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
......@@ -14,7 +15,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 调用者记录
......@@ -34,17 +35,23 @@ public class LogCallHttpAspect {
@Around("logHttpCaller()")
public Object record(ProceedingJoinPoint pjp) throws Throwable {
Object result = pjp.proceed();
Stopwatch stopwatch = Stopwatch.createStarted();
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (Objects.nonNull(attrs)) {
try {
HttpServletRequest request = attrs.getRequest();
String remoteIP = IPUtil.getRemoteIP(request);
Object[] args = pjp.getArgs();
LOGGER.info("http api is called,from IP:[{}],args:[{}]", remoteIP, args);
} catch (Exception e) {
LOGGER.error("打印http请求日志出错", e);
}
HttpServletRequest request = attrs.getRequest();
String remoteIP = IPUtil.getRemoteIP(request);
Object[] args = pjp.getArgs();
boolean hasException = false;
Object result;
try {
result = pjp.proceed();
} catch (Throwable e) {
hasException = true;
throw e;
} finally {
Stopwatch stop = stopwatch.stop();
long elapsed = stop.elapsed(TimeUnit.MILLISECONDS);
LOGGER.info("[httpRequestLog],url:[{}],remoteIP:[{}],args:[{}],duration:[{}],exception:[{}]",
request.getRequestURL(), remoteIP, args, elapsed, hasException);
}
return result;
}
......
......@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.util.IPUtil;
import cn.quantgroup.xyqb.util.MqUtils;
import cn.quantgroup.xyqb.util.ValidationUtil;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -63,6 +64,7 @@ public class AppController implements IBaseController {
@IpValidator
@RequestMapping("/login")
@ApiOperation(value = "/login", notes = "App登陆")
public JsonResult login(
String phoneNo,
String idNo, String name, String key,
......@@ -162,10 +164,10 @@ public class AppController implements IBaseController {
context.setAppChannel(appChannel);
loginInfo.setLoginContext(context);
LOGGER.info("第三方用户获取信息登录成功 [AppController] loginSuper --> loginFrom:{}, phoneNo:{},appChannel:{},channelId:{}", registerFrom, phoneNo, appChannel, channelId);
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
/*
* 部分免密渠道登录统计,用户中心不需识别,由统计平台来过滤
* 贷款导航(84660);壹账通H5(159384)
*/
user.setRegisteredFrom(registerFrom);
UserStatistics statistics = new UserStatistics(user, null, 4, channelId);
//增加登陆统计发送
......
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