package com.kxs.common.log;

import com.kxs.common.log.aspect.SysLogAspect;
import com.kxs.common.log.config.SkyLogProperties;
import com.kxs.common.log.event.SysLogListener;
import com.kxs.system.api.feign.RemoteLogService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * 日志自动配置
 *
 * @author 没秃顶的码农
 * @date 2023/10/28
 */
@EnableAsync
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(SkyLogProperties.class)
@ConditionalOnProperty(value = "security.log.enabled", matchIfMissing = true)
public class LogAutoConfiguration {

	@Bean
	public SysLogListener sysLogListener(SkyLogProperties logProperties, RemoteLogService remoteLogService) {
		return new SysLogListener(remoteLogService, logProperties);
	}

	@Bean
	public SysLogAspect sysLogAspect() {
		return new SysLogAspect();
	}

}
