Class: Appsignal::Config

Inherits:
Object
  • Object
show all
Includes:
CarefulLogger
Defined in:
lib/appsignal/config.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  :ignore_exceptions => [],
  :endpoint => 'https://push.appsignal.com/1',
  :slow_request_threshold => 200
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CarefulLogger

#carefully_log_error

Constructor Details

#initialize(root_path, env, logger = Appsignal.logger) ⇒ Config



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/appsignal/config.rb', line 17

def initialize(root_path, env, logger=Appsignal.logger)
  @root_path = root_path
  @env = env
  @logger = logger

  if File.exists?(config_file)
    load_config_from_disk
  elsif ENV['APPSIGNAL_PUSH_API_KEY']
    load_default_config_with_push_api_key(
      ENV['APPSIGNAL_PUSH_API_KEY']
    )
  elsif ENV['APPSIGNAL_API_KEY']
    load_default_config_with_push_api_key(
      ENV['APPSIGNAL_API_KEY']
    )
  else
    carefully_log_error(
      "Not loading: No config file found at '#{config_file}' " \
      "and no APPSIGNAL_PUSH_API_KEY env var present"
    )
  end
end

Instance Attribute Details

#config_hashObject (readonly)

Returns the value of attribute config_hash.



15
16
17
# File 'lib/appsignal/config.rb', line 15

def config_hash
  @config_hash
end

#envObject (readonly)

Returns the value of attribute env.



15
16
17
# File 'lib/appsignal/config.rb', line 15

def env
  @env
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



15
16
17
# File 'lib/appsignal/config.rb', line 15

def root_path
  @root_path
end

Instance Method Details

#[](key) ⇒ Object



44
45
46
47
# File 'lib/appsignal/config.rb', line 44

def [](key)
  return unless loaded?
  config_hash[key]
end

#loaded?Boolean



40
41
42
# File 'lib/appsignal/config.rb', line 40

def loaded?
  !! config_hash
end