Sha256: 320f88089826644f29d32a1db339a90feab955646fef3ca2944d0cb185004531

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

module TreasureData
module Logger
module Agent::Rails

  CONFIG_PATH = 'config/treasure_data.yml'
  CONFIG_PATH_EY_LOCAL = 'config/ey_services_config_local.yml'
  CONFIG_PATH_EY_DEPLOY = 'config/ey_services_config_deploy.yml'

  require 'td/logger/agent/rack'
  require 'td/logger/agent/rails/config'
  require 'td/logger/agent/rails/controller'
  #require 'td/logger/agent/rails/model'

  def self.init(rails)
    c = Config.init
    unless c
      ::TreasureData::Logger.open_null
      return false
    end

    if c.agent_mode?
      ::TreasureData::Logger.open_agent(c.tag, :host=>c.agent_host, :port=>c.agent_port, :debug=>c.debug_mode)
    else
      ::TreasureData::Logger.open(c.database, :apikey=>c.apikey, :auto_create_table=>c.auto_create_table, :debug=>c.debug_mode)
    end

    rails.middleware.use Agent::Rack::Hook

    Agent::Rack::Hook.before do |env|
      TreasureData::Logger.event.attribute.clear
    end

    Agent::Rails::ControllerExtension.init
    #Agent::Rails::AccessLogger.init(c.access_log_table) if c.access_log_enabled?
    #Agent::Rails::ModelExtension.init

    true
  end

  if ::Rails.respond_to?(:version) && ::Rails.version =~ /^3/
    class Railtie < ::Rails::Railtie
      initializer "treasure_data_logger.start_plugin" do |app|
        TreasureData::Logger::Agent::Rails.init(app.config)
      end
    end
  else
    TreasureData::Logger::Agent::Rails.init(::Rails.configuration)
  end

end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
td-logger-0.3.12 lib/td/logger/agent/rails.rb
td-logger-0.3.11 lib/td/logger/agent/rails.rb
td-logger-0.3.10 lib/td/logger/agent/rails.rb
td-logger-0.3.9 lib/td/logger/agent/rails.rb
td-logger-0.3.8 lib/td/logger/agent/rails.rb