net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener Java Examples

The following examples show how to use net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProxyDataSourceConfigurationTests.java    From spring-boot-data-source-decorator with Apache License 2.0 5 votes vote down vote up
@Test
void testRegisterLogAndSlowQueryLogByDefaultToSlf4j() {
    contextRunner.run(context -> {
        DataSource dataSource = context.getBean(DataSource.class);
        ProxyDataSource proxyDataSource = (ProxyDataSource) ((DecoratedDataSource) dataSource).getDecoratedDataSource();
        ChainListener chainListener = proxyDataSource.getProxyConfig().getQueryListener();
        assertThat(chainListener.getListeners()).extracting("class").contains(SLF4JSlowQueryListener.class);
        assertThat(chainListener.getListeners()).extracting("class").contains(SLF4JQueryLoggingListener.class);
    });
}
 
Example #2
Source File: ProxyDataSourceConfigurationTests.java    From spring-boot-data-source-decorator with Apache License 2.0 5 votes vote down vote up
@Test
void testRegisterLogAndSlowQueryLogByUsingSlf4j() {
    ApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues("decorator.datasource.datasource-proxy.logging:slf4j");

    contextRunner.run(context -> {
        DataSource dataSource = context.getBean(DataSource.class);
        ProxyDataSource proxyDataSource = (ProxyDataSource) ((DecoratedDataSource) dataSource).getDecoratedDataSource();
        ChainListener chainListener = proxyDataSource.getProxyConfig().getQueryListener();
        assertThat(chainListener.getListeners()).extracting("class").contains(SLF4JSlowQueryListener.class);
        assertThat(chainListener.getListeners()).extracting("class").contains(SLF4JQueryLoggingListener.class);
    });
}
 
Example #3
Source File: ResourceLocalReleaseAfterStatementConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}
 
Example #4
Source File: JPATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}
 
Example #5
Source File: JTATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn(value = {"btmConfig", "actualDataSource"})
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}
 
Example #6
Source File: HibernateTransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}
 
Example #7
Source File: BehaviorDrivenInheritanceConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Bean
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}
 
Example #8
Source File: DataSourceProxyConnectionProvider.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(Map configValues) {
    super.configure(configValues);
    DataSource dataSource = ProxyDataSourceBuilder
            .create(getDataSource())
            .name(getClass().getSimpleName())
            .listener(new SLF4JQueryLoggingListener())
            .build();
    super.setDataSource(dataSource);
}
 
Example #9
Source File: AbstractJPAConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
private DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
        .create(actualDataSource())
        .name(DATA_SOURCE_PROXY_NAME)
        .listener(loggingListener)
        .build();
}
 
Example #10
Source File: AbstractJTATransactionManagerConfiguration.java    From high-performance-java-persistence with Apache License 2.0 5 votes vote down vote up
@DependsOn(value = {"btmConfig", "actualDataSource"})
public DataSource dataSource() {
    SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
    loggingListener.setQueryLogEntryCreator(new InlineQueryLogEntryCreator());
    return ProxyDataSourceBuilder
            .create(actualDataSource())
            .name(DATA_SOURCE_PROXY_NAME)
            .listener(loggingListener)
            .build();
}