

package com.nantian.sc.cloud.common.log;

import com.nantian.sc.cloud.admin.api.feign.RemoteLogService;
import com.nantian.sc.cloud.admin.api.feign.RemoteOperationLogService;
import com.nantian.sc.cloud.admin.api.log.OperationLogAspect;
import com.nantian.sc.cloud.common.log.aspect.SysLogAspect;
import com.nantian.sc.cloud.common.log.event.SysLogListener;
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;

/**
 * @author
 * @date 2018/6/28
 * <p>
 * 日志自动配置
 */
@EnableAsync
@Configuration
@AllArgsConstructor
@ConditionalOnWebApplication
public class LogAutoConfiguration {
	private final RemoteLogService remoteLogService;
	private final RemoteOperationLogService remoteOperationLogService;

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

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

	@Bean
	public OperationLogAspect operationLogAspect() {
		return new OperationLogAspect(remoteOperationLogService);
	}
}
