Merge remote-tracking branch 'origin/group5-log'

pull/3/head
fengshuonan 2020-12-29 17:41:47 +08:00
commit e5b506191c
2 changed files with 28 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.core.Ordered;
import org.springframework.core.ParameterNameDiscoverer;
import org.springframework.ui.Model;
import java.lang.reflect.Method;
import java.util.HashMap;
@ -170,7 +171,12 @@ public class RequestApiLogRecordAop implements Ordered {
// 处理基本类型
Class<?>[] classes = new Class[args.length];
for (int k = 0; k < args.length; k++) {
classes[k] = args[k].getClass();
if(args[k] instanceof Model){
classes[k] = Model.class;
}else{
classes[k] = args[k].getClass();
}
}
ParameterNameDiscoverer defaultParameterNameDiscoverer = new DefaultParameterNameDiscoverer();

View File

@ -9,10 +9,13 @@ import cn.stylefeng.roses.kernel.log.api.pojo.log.SysLogProperties;
import cn.stylefeng.roses.kernel.log.api.threadpool.LogManagerThreadPool;
import cn.stylefeng.roses.kernel.log.db.DbLogManagerServiceImpl;
import cn.stylefeng.roses.kernel.log.db.DbLogRecordServiceImpl;
import cn.stylefeng.roses.kernel.log.db.service.SysLogService;
import cn.stylefeng.roses.kernel.log.db.service.impl.SysLogServiceImpl;
import cn.stylefeng.roses.kernel.log.file.FileLogManagerServiceImpl;
import cn.stylefeng.roses.kernel.log.file.FileLogRecordServiceImpl;
import cn.stylefeng.roses.kernel.log.modular.requestapi.aop.RequestApiLogRecordAop;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -31,6 +34,21 @@ public class GunsLogAutoConfiguration {
*/
public static final String SYS_LOG_PREFIX = "sys-log";
/**
* service
*
* @return sysLogService
* @author liuhanqing
* @date 2020/12/28 22:09
*/
@Bean
@ConditionalOnMissingBean(SysLogServiceImpl.class)
@ConditionalOnProperty(prefix = SYS_LOG_PREFIX, name = "type", havingValue = "db")
public SysLogService sysLogService() {
return new SysLogServiceImpl();
}
/**
*
*
@ -49,11 +67,12 @@ public class GunsLogAutoConfiguration {
* db-file-
*
* @param sysLogProperties
* @param sysLogService service
* @author liuhanqing
* @date 2020/12/20 13:02
*/
@Bean
public RequestApiLogRecordAop requestApiLogRecordAop(SysLogProperties sysLogProperties) {
public RequestApiLogRecordAop requestApiLogRecordAop(SysLogProperties sysLogProperties, SysLogServiceImpl sysLogService) {
// 如果类型是文件
if (StrUtil.isNotBlank(sysLogProperties.getType())
@ -71,7 +90,7 @@ public class GunsLogAutoConfiguration {
}
// 其他情况用数据库存储日志
return new RequestApiLogRecordAop(new DbLogRecordServiceImpl(new LogManagerThreadPool(), new SysLogServiceImpl()));
return new RequestApiLogRecordAop(new DbLogRecordServiceImpl(new LogManagerThreadPool(), sysLogService));
}
/**