Class: Appsignal::Config
- Inherits:
-
Object
- Object
- Appsignal::Config
- Includes:
- CarefulLogger
- Defined in:
- lib/appsignal/config.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ :ignore_exceptions => [], :ignore_actions => [], :send_params => true, :endpoint => 'https://push.appsignal.com/1', :slow_request_threshold => 200, :instrument_net_http => true, :skip_session_data => false, :enable_frontend_error_catching => false, :frontend_error_catching_path => '/appsignal_error_catcher' }.freeze
Instance Attribute Summary collapse
-
#config_hash ⇒ Object
readonly
Returns the value of attribute config_hash.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#initial_config ⇒ Object
readonly
Returns the value of attribute initial_config.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #active? ⇒ Boolean
-
#initialize(root_path, env, initial_config = {}, logger = Appsignal.logger) ⇒ Config
constructor
A new instance of Config.
- #loaded? ⇒ Boolean
Methods included from CarefulLogger
Constructor Details
#initialize(root_path, env, initial_config = {}, logger = Appsignal.logger) ⇒ Config
Returns a new instance of Config.
23 24 25 26 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 52 53 54 55 |
# File 'lib/appsignal/config.rb', line 23 def initialize(root_path, env, initial_config={}, logger=Appsignal.logger) @root_path = root_path @env = env.to_s @initial_config = initial_config @logger = logger if File.exists?(config_file) load_config_from_disk elsif ENV['APPSIGNAL_PUSH_API_KEY'] load_default_config_with_push_api_key_and_name_from_env( ENV['APPSIGNAL_PUSH_API_KEY'] ) elsif ENV['APPSIGNAL_API_KEY'] load_default_config_with_push_api_key_and_name_from_env( ENV['APPSIGNAL_API_KEY'] ) @logger.info( 'The APPSIGNAL_API_KEY environment variable has been deprecated, ' \ 'please switch to APPSIGNAL_PUSH_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 if config_hash && !config_hash[:name] @logger.debug( "There's no application name set in your config file or in the APPSIGNAL_APP_NAME env var. " \ "You should set one unless your app runs on Heroku." ) end end |
Instance Attribute Details
#config_hash ⇒ Object (readonly)
Returns the value of attribute config_hash.
21 22 23 |
# File 'lib/appsignal/config.rb', line 21 def config_hash @config_hash end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
21 22 23 |
# File 'lib/appsignal/config.rb', line 21 def env @env end |
#initial_config ⇒ Object (readonly)
Returns the value of attribute initial_config.
21 22 23 |
# File 'lib/appsignal/config.rb', line 21 def initial_config @initial_config end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
21 22 23 |
# File 'lib/appsignal/config.rb', line 21 def root_path @root_path end |
Instance Method Details
#[](key) ⇒ Object
61 62 63 64 |
# File 'lib/appsignal/config.rb', line 61 def [](key) return unless loaded? config_hash[key] end |
#active? ⇒ Boolean
66 67 68 |
# File 'lib/appsignal/config.rb', line 66 def active? !! self[:active] end |
#loaded? ⇒ Boolean
57 58 59 |
# File 'lib/appsignal/config.rb', line 57 def loaded? !! config_hash end |