<commit_before>require_relative 'app'
require 'active_record'
require 'logger'
require 'settingslogic'

module Days
  class Config < Settingslogic
    namespace App.environment.to_s

    def initialize(hash_or_file = {}, section = nil)
      super
      if section.nil?
        if String === hash_or_file
          self[:root] = File.dirname(hash_or_file)
        else
          self[:root] = "."
        end

        self['database'].tap do |hash|
          next unless hash
          if hash['adapter'] == 'sqlite3' && /^\// !~ hash['database']
            hash['database'] = File.join(self.root, hash['database'])
          end
        end
      end
    end

    def establish_db_connection(force=false)
      if !self.has_key?(:activerecord_log) || self.activerecord_log == true
        ActiveRecord::Base.logger = Logger.new($stdout)
      end

      begin
        raise ActiveRecord::ConnectionNotEstablished if force
        return ActiveRecord::Base.connection
      rescue ActiveRecord::ConnectionNotEstablished
        ActiveRecord::Base.establish_connection(self['database'] ? Hash[self.database] : ENV["DATABASE_URL"])
        retry
      end
    end
  end
end<commit_msg>Now you can disable AR::Base.logger<commit_after>require_relative 'app'
require 'active_record'
require 'logger'
require 'settingslogic'

module Days
  class Config < Settingslogic
    namespace App.environment.to_s

    def initialize(hash_or_file = {}, section = nil)
      super
      if section.nil?
        if String === hash_or_file
          self[:root] = File.dirname(hash_or_file)
        else
          self[:root] = "."
        end

        self['database'].tap do |hash|
          next unless hash
          if hash['adapter'] == 'sqlite3' && /^\// !~ hash['database']
            hash['database'] = File.join(self.root, hash['database'])
          end
        end
      end
    end

    def establish_db_connection(force=false)
      if Days::App.environment.to_sym == :development && (self.has_key?(:activerecord_log) ? true : self.activerecord_log == true)
        ActiveRecord::Base.logger = Logger.new($stdout)
      end

      begin
        raise ActiveRecord::ConnectionNotEstablished if force
        return ActiveRecord::Base.connection
      rescue ActiveRecord::ConnectionNotEstablished
        ActiveRecord::Base.establish_connection(self['database'] ? Hash[self.database] : ENV["DATABASE_URL"])
        retry
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11083844580777096, 'fraction_numerical': 0.0008179959100204499, 'mean_word_length': 2.6507462686567163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5151820', 'n_tokens_mistral': 708, 'n_tokens_neox': 684, 'n_words': 152}