Class: TreasureData::Logger::Agent::Rails::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/td/logger/agent/rails.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf, rails_config) ⇒ Config

Returns a new instance of Config.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/td/logger/agent/rails.rb', line 27

def initialize(conf, rails_config)
  @rails_config = rails_config

  if agent = conf['agent']
    host, port = agent.split(':',2)
    port = (port || 24224).to_i
    @agent_host = host
    @agent_port = port

    @tag = conf['tag']
    @tag ||= conf['database']
    raise "'tag' nor 'database' options are not set" unless @tag

  else
    @apikey = conf['apikey']
    raise "'apikey' option is not set" unless @apikey

    @database = conf['database']
    raise "'database' option is not set" unless @database

    @auto_create_table = !!conf['auto_create_table']
  end

  @access_log_table = conf['access_log_table']
end

Instance Attribute Details

#access_log_tableObject (readonly)

Returns the value of attribute access_log_table.



56
57
58
# File 'lib/td/logger/agent/rails.rb', line 56

def access_log_table
  @access_log_table
end

#agent_hostObject (readonly)

Returns the value of attribute agent_host.



54
55
56
# File 'lib/td/logger/agent/rails.rb', line 54

def agent_host
  @agent_host
end

#agent_portObject (readonly)

Returns the value of attribute agent_port.



54
55
56
# File 'lib/td/logger/agent/rails.rb', line 54

def agent_port
  @agent_port
end

#apikeyObject (readonly)

Returns the value of attribute apikey.



55
56
57
# File 'lib/td/logger/agent/rails.rb', line 55

def apikey
  @apikey
end

#auto_create_tableObject (readonly)

Returns the value of attribute auto_create_table.



55
56
57
# File 'lib/td/logger/agent/rails.rb', line 55

def auto_create_table
  @auto_create_table
end

#databaseObject (readonly)

Returns the value of attribute database.



55
56
57
# File 'lib/td/logger/agent/rails.rb', line 55

def database
  @database
end

#rails_configObject (readonly)

Returns the value of attribute rails_config.



53
54
55
# File 'lib/td/logger/agent/rails.rb', line 53

def rails_config
  @rails_config
end

#tagObject (readonly)

Returns the value of attribute tag.



54
55
56
# File 'lib/td/logger/agent/rails.rb', line 54

def tag
  @tag
end

Instance Method Details

#access_log_enabled?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/td/logger/agent/rails.rb', line 62

def access_log_enabled?
  !@access_log_table.nil? && !@access_log_table.empty?
end

#agent_mode?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/td/logger/agent/rails.rb', line 58

def agent_mode?
  @agent_host != nil
end