package com.tofly.common.log.config;

import com.tofly.base.api.feign.BaseLogService;
import com.tofly.common.log.aspect.LogAspect;
import com.tofly.common.log.event.SysLogListener;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author Administrator
 * @date 2019/9/11  17:01
 * 日志自动配置
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {
	private final BaseLogService baseLogService;

	private Environment environment;

	@Bean
	public SysLogListener sysLogListener() {
		return new SysLogListener(baseLogService,environment);
	}



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