Class: TreasureData::Logger::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/td/logger.rb', line 7

def initialize(conf)
  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
end

Instance Attribute Details

#agent_hostObject (readonly)

Returns the value of attribute agent_host.



29
30
31
# File 'lib/td/logger.rb', line 29

def agent_host
  @agent_host
end

#agent_portObject (readonly)

Returns the value of attribute agent_port.



29
30
31
# File 'lib/td/logger.rb', line 29

def agent_port
  @agent_port
end

#apikeyObject (readonly)

Returns the value of attribute apikey.



30
31
32
# File 'lib/td/logger.rb', line 30

def apikey
  @apikey
end

#auto_create_tableObject (readonly)

Returns the value of attribute auto_create_table.



30
31
32
# File 'lib/td/logger.rb', line 30

def auto_create_table
  @auto_create_table
end

#databaseObject (readonly)

Returns the value of attribute database.



30
31
32
# File 'lib/td/logger.rb', line 30

def database
  @database
end

#tagObject (readonly)

Returns the value of attribute tag.



29
30
31
# File 'lib/td/logger.rb', line 29

def tag
  @tag
end

Instance Method Details

#agent_mode?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/td/logger.rb', line 32

def agent_mode?
  @agent_host != nil
end