lib/td/logger/agent/rails.rb in td-logger-0.2.1 vs lib/td/logger/agent/rails.rb in td-logger-0.2.2

- old
+ new

@@ -81,21 +81,25 @@ !@access_log_table.nil? && !@access_log_table.empty? end end def self.read_config(rails) + require 'yaml' + require 'erb' logger = ::Rails.logger || ::Logger.new(STDOUT) begin - yaml = YAML.load_file("#{rails_root}/#{CONFIG_PATH}") + src = File.read("#{rails_root}/#{CONFIG_PATH}") + yaml = ERB.new(src).result + env_conf = YAML.load(yaml) rescue logger.warn "Can't load #{CONFIG_PATH} file." logger.warn " #{$!}" logger.warn "Put the following file:" logger.warn CONFIG_SAMPLE return end - conf = yaml[rails_env] + conf = env_conf[rails_env] unless conf logger.warn "#{CONFIG_PATH} doesn't include setting for current environment (#{rails_env})." logger.warn "Disabling Treasure Data logger." return end