package com.lutao.cloud.common.log;

import com.lutao.cloud.common.log.event.SysLogListener;
import com.lutao.cloud.admin.api.feign.RemoteLogService;
import com.lutao.cloud.common.core.util.KeyStrResolver;
import com.lutao.cloud.common.log.aspect.SysLogAspect;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**

 * @date 2018/6/28
 * <p>
 * 日志自动配置
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration{

	private final RemoteLogService remoteLogService;

	@Bean
	public SysLogListener sysLogListener(){
		return new SysLogListener(remoteLogService);
	}

	@Bean
	public SysLogAspect sysLogAspect(ApplicationEventPublisher publisher, KeyStrResolver resolver){
		return new SysLogAspect(publisher, resolver);
	}

}
