org.zodiac.autoconfigure.log.PlatformLogToolAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.log;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.application.ApplicationInfoProperties;
import org.zodiac.autoconfigure.launcher.ServerConfigProperties;
import org.zodiac.autoconfigure.log.condition.ConditionalOnPatformLogRequestEnabled;
import org.zodiac.core.context.annotation.ImportPropertySources;
@ConditionalOnWebApplication
@ConditionalOnPatformLogRequestEnabled
@SpringBootConfiguration
@ImportPropertySources(value = {"classpath:/META-INF/config/log.yml"})
//@EnableConfigurationProperties(value = {PlatformRequestLogProperties.class})
@ConditionalOnClass(value = {org.zodiac.log.LogOperations.class, org.aspectj.lang.annotation.Pointcut.class})
public class PlatformLogToolAutoConfiguration {
public PlatformLogToolAutoConfiguration() {
super();
}
@Bean
//@AppRefreshScope
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = org.zodiac.log.constants.PlatformLogSystemPropertiesConstants.LOGGING_REQUEST_PREFIX)
protected PlatformRequestLogProperties platformRequestLogProperties() {
return new PlatformRequestLogProperties();
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.log.aspect.ApiLogAspect apiLogAspect(org.zodiac.log.publisher.ApiLogApplicationPublisher apiLogPublisher) {
return new org.zodiac.log.aspect.ApiLogAspect(apiLogPublisher);
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.log.aspect.LogTraceAspect logTraceAspect() {
return new org.zodiac.log.aspect.LogTraceAspect();
}
@Bean
@ConditionalOnMissingBean
protected org.zodiac.log.logger.PlatformLogger platformLogger(ApplicationInfoProperties applicationInfoProperties, org.zodiac.log.publisher.UsualLogApplicationPublisher usualLogPublisher) {
return new org.zodiac.log.logger.PlatformLogger(applicationInfoProperties.getName(), usualLogPublisher);
}
@Bean
@ConditionalOnMissingBean(value = {org.zodiac.log.service.PlatformLogService.class})
protected org.zodiac.log.service.PlatformLogService platformLogService() {
return new org.zodiac.log.feign.FeignLogClientFallback();
}
@Bean
@ConditionalOnMissingBean(name = org.zodiac.log.constants.PlatformLogConstants.API_LOG_LISTENER_BEAN_NAME)
protected org.zodiac.log.event.ApiLogListener apiLogListener(ObjectProvider logServiceProvider, ServerConfigProperties serverInfo,
ApplicationInfoProperties applicationInfoProperties) {
return new org.zodiac.log.event.ApiLogListener(logServiceProvider.getIfAvailable(), serverInfo, applicationInfoProperties);
}
@Bean
@ConditionalOnMissingBean(name = org.zodiac.log.constants.PlatformLogConstants.ERROR_LOG_LISTENER_BEAN_NAME)
protected org.zodiac.log.event.ErrorLogListener errorEventListener(ObjectProvider logServiceProvider, ServerConfigProperties serverInfo,
ApplicationInfoProperties applicationInfoProperties) {
return new org.zodiac.log.event.ErrorLogListener(logServiceProvider.getIfAvailable(), serverInfo, applicationInfoProperties);
}
@Bean
@ConditionalOnMissingBean(name = org.zodiac.log.constants.PlatformLogConstants.USUAL_LOG_LISTENER_BEAN_NAME)
protected org.zodiac.log.event.UsualLogListener usualEventListener(ObjectProvider logServiceProvider, ServerConfigProperties serverInfo,
ApplicationInfoProperties applicationInfoProperties) {
return new org.zodiac.log.event.UsualLogListener(logServiceProvider.getIfAvailable(), serverInfo, applicationInfoProperties);
}
}