Class: Airbrake::Config
- Inherits:
-
Object
- Object
- Airbrake::Config
- Defined in:
- lib/airbrake-ruby/config.rb
Overview
Represents the Airbrake config. A config contains all the options that you can use to configure an Airbrake instance.
Instance Attribute Summary collapse
-
#app_version ⇒ String
The version of the user’s application.
-
#environment ⇒ String, Symbol
The environment the application is running in.
-
#host ⇒ String
The host, which provides the API endpoint to which exceptions should be sent.
-
#ignore_environments ⇒ Array<String, Symbol>
The array of environments that forbids sending exceptions when the application is running in them.
-
#logger ⇒ Logger
The default logger used for debug output.
-
#project_id ⇒ Integer
The project identificator.
-
#project_key ⇒ String
The project key.
-
#proxy ⇒ Hash
The proxy parameters such as (:host, :port, :user and :password).
-
#queue_size ⇒ Integer
The max number of notices that can be queued up.
-
#root_directory ⇒ String, Pathname
The working directory of your project.
-
#workers ⇒ Integer
The number of worker threads that process the notice queue.
Instance Method Summary collapse
-
#endpoint ⇒ URI
The full URL to the Airbrake Notice API.
-
#initialize(user_config = {}) ⇒ Config
constructor
A new instance of Config.
-
#merge(config_hash) ⇒ self
Merges the given
config_hashwith itself.
Constructor Details
#initialize(user_config = {}) ⇒ Config
Returns a new instance of Config.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/airbrake-ruby/config.rb', line 59 def initialize(user_config = {}) self.proxy = {} self.queue_size = 100 self.workers = 1 self.logger = Logger.new(STDOUT) logger.level = Logger::WARN self.project_id = user_config[:project_id] self.project_key = user_config[:project_key] self.host = 'https://airbrake.io' self.ignore_environments = [] merge(user_config) end |
Instance Attribute Details
#app_version ⇒ String
Returns the version of the user’s application.
25 26 27 |
# File 'lib/airbrake-ruby/config.rb', line 25 def app_version @app_version end |
#environment ⇒ String, Symbol
Returns the environment the application is running in.
47 48 49 |
# File 'lib/airbrake-ruby/config.rb', line 47 def environment @environment end |
#host ⇒ String
Returns the host, which provides the API endpoint to which exceptions should be sent.
39 40 41 |
# File 'lib/airbrake-ruby/config.rb', line 39 def host @host end |
#ignore_environments ⇒ Array<String, Symbol>
Returns the array of environments that forbids sending exceptions when the application is running in them. Other possible environments not listed in the array will allow sending occurring exceptions.
54 55 56 |
# File 'lib/airbrake-ruby/config.rb', line 54 def ignore_environments @ignore_environments end |
#logger ⇒ Logger
Returns the default logger used for debug output.
21 22 23 |
# File 'lib/airbrake-ruby/config.rb', line 21 def logger @logger end |
#project_id ⇒ Integer
Returns the project identificator. This value must be set.
8 9 10 |
# File 'lib/airbrake-ruby/config.rb', line 8 def project_id @project_id end |
#project_key ⇒ String
Returns the project key. This value must be set.
12 13 14 |
# File 'lib/airbrake-ruby/config.rb', line 12 def project_key @project_key end |
#proxy ⇒ Hash
Returns the proxy parameters such as (:host, :port, :user and :password).
17 18 19 |
# File 'lib/airbrake-ruby/config.rb', line 17 def proxy @proxy end |
#queue_size ⇒ Integer
Returns the max number of notices that can be queued up.
29 30 31 |
# File 'lib/airbrake-ruby/config.rb', line 29 def queue_size @queue_size end |
#root_directory ⇒ String, Pathname
Returns the working directory of your project.
43 44 45 |
# File 'lib/airbrake-ruby/config.rb', line 43 def root_directory @root_directory end |
#workers ⇒ Integer
Returns the number of worker threads that process the notice queue.
34 35 36 |
# File 'lib/airbrake-ruby/config.rb', line 34 def workers @workers end |
Instance Method Details
#endpoint ⇒ URI
The full URL to the Airbrake Notice API. Based on the :host option.
79 80 81 82 83 84 85 86 |
# File 'lib/airbrake-ruby/config.rb', line 79 def endpoint @endpoint ||= begin self.host = ('https://' << host) if host !~ %r{\Ahttps?://} api = "/api/v3/projects/#{project_id}/notices?key=#{project_key}" URI.join(host, api) end end |
#merge(config_hash) ⇒ self
Merges the given config_hash with itself.
102 103 104 105 |
# File 'lib/airbrake-ruby/config.rb', line 102 def merge(config_hash) config_hash.each_pair { |option, value| set_option(option, value) } self end |