<commit_before>package io.smartcat.cassandra.diagnostics;

import com.google.inject.AbstractModule;

import io.smartcat.cassandra.diagnostics.config.Configuration;
import io.smartcat.cassandra.diagnostics.config.ConfigurationException;
import io.smartcat.cassandra.diagnostics.config.ConfigurationLoader;
import io.smartcat.cassandra.diagnostics.config.YamlConfigurationLoader;
import io.smartcat.cassandra.diagnostics.jmx.DiagnosticsMXBean;
import io.smartcat.cassandra.diagnostics.jmx.DiagnosticsMXBeanImpl;
import io.smartcat.cassandra.diagnostics.report.LogQueryReporter;
import io.smartcat.cassandra.diagnostics.report.QueryReporter;

/**
 * Defines the main DI bindings.
 */
public class DiagnosticsModule extends AbstractModule {

  @SuppressWarnings("unchecked")
  @Override
  protected void configure() {
    ConfigurationLoader loader = new YamlConfigurationLoader();
    Configuration config;

    try {
      config = loader.loadConfig();
    } catch (ConfigurationException e) {
      config = new Configuration();
    }

    bind(ConfigurationLoader.class).toInstance(loader);
    bind(Configuration.class).toInstance(config);

    try {
      bind(QueryReporter.class).to((Class<? extends QueryReporter>) Class.forName(config.reporter));
    } catch (ClassNotFoundException e) {
      bind(QueryReporter.class).to(LogQueryReporter.class);
    }

    bind(DiagnosticsMXBean.class).to(DiagnosticsMXBeanImpl.class);
  }

}<commit_msg>Logging configuration loading problems and effective configuration.<commit_after>package io.smartcat.cassandra.diagnostics;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.AbstractModule;

import io.smartcat.cassandra.diagnostics.config.Configuration;
import io.smartcat.cassandra.diagnostics.config.ConfigurationException;
import io.smartcat.cassandra.diagnostics.config.ConfigurationLoader;
import io.smartcat.cassandra.diagnostics.config.YamlConfigurationLoader;
import io.smartcat.cassandra.diagnostics.jmx.DiagnosticsMXBean;
import io.smartcat.cassandra.diagnostics.jmx.DiagnosticsMXBeanImpl;
import io.smartcat.cassandra.diagnostics.report.LogQueryReporter;
import io.smartcat.cassandra.diagnostics.report.QueryReporter;

/**
 * Defines the main DI bindings.
 */
public class DiagnosticsModule extends AbstractModule {

  private static final Logger logger = LoggerFactory.getLogger(DiagnosticsModule.class);

  @SuppressWarnings("unchecked")
  @Override
  protected void configure() {
    ConfigurationLoader loader = new YamlConfigurationLoader();
    Configuration config;

    try {
      config = loader.loadConfig();
    } catch (ConfigurationException e) {
      logger.warn("A problem occured while loading configuration. Using default configuration.", e);
      config = new Configuration();
    }
    logger.info("Effective configuration: {}", config);

    bind(ConfigurationLoader.class).toInstance(loader);
    bind(Configuration.class).toInstance(config);

    try {
      bind(QueryReporter.class).to((Class<? extends QueryReporter>) Class.forName(config.reporter));
    } catch (ClassNotFoundException e) {
      bind(QueryReporter.class).to(LogQueryReporter.class);
    }

    bind(DiagnosticsMXBean.class).to(DiagnosticsMXBeanImpl.class);
  }

}
{'fraction_non_alphanumeric': 0.1021224238695786, 'fraction_numerical': 0.0006151953245155337, 'mean_word_length': 5.290135396518375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5832982', 'n_tokens_mistral': 911, 'n_tokens_neox': 910, 'n_words': 153}