mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 12:48:58 +08:00
Merge branch 'jdk17' into jdk17-dev
This commit is contained in:
commit
27ac5fd17a
@ -16,7 +16,9 @@
|
||||
|
||||
package com.pig4cloud.pig.auth.support.handler;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pig.admin.api.entity.SysLog;
|
||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||
import com.pig4cloud.pig.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pig.common.core.util.WebUtils;
|
||||
import com.pig4cloud.pig.common.log.event.SysLogEvent;
|
||||
@ -57,19 +59,25 @@ public class PigLogoutSuccessEventHandler implements ApplicationListener<LogoutS
|
||||
log.info("用户:{} 退出成功", authentication.getPrincipal());
|
||||
SysLog logVo = SysLogUtils.getSysLog();
|
||||
logVo.setTitle("退出成功");
|
||||
// 发送异步日志事件
|
||||
Long startTime = System.currentTimeMillis();
|
||||
Long endTime = System.currentTimeMillis();
|
||||
logVo.setTime(endTime - startTime);
|
||||
|
||||
// 设置对应的token
|
||||
WebUtils.getRequest().ifPresent(request -> logVo.setParams(request.getHeader(HttpHeaders.AUTHORIZATION)));
|
||||
WebUtils.getRequest().ifPresent(request -> {
|
||||
logVo.setParams(request.getHeader(HttpHeaders.AUTHORIZATION));
|
||||
// 计算请求耗时
|
||||
String startTimeStr = request.getHeader(CommonConstants.REQUEST_START_TIME);
|
||||
if (StrUtil.isNotBlank(startTimeStr)) {
|
||||
Long startTime = Long.parseLong(startTimeStr);
|
||||
Long endTime = System.currentTimeMillis();
|
||||
logVo.setTime(endTime - startTime);
|
||||
}
|
||||
});
|
||||
|
||||
// 这边设置ServiceId
|
||||
if (authentication instanceof PreAuthenticatedAuthenticationToken) {
|
||||
logVo.setServiceId(authentication.getCredentials().toString());
|
||||
}
|
||||
logVo.setCreateBy(authentication.getName());
|
||||
// 发送异步日志事件
|
||||
SpringContextHolder.publishEvent(new SysLogEvent(logVo));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user