Class: Errsight::Configuration
- Inherits:
-
Object
- Object
- Errsight::Configuration
- Defined in:
- lib/errsight/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#attach_to_rails_logger ⇒ Object
Returns the value of attribute attach_to_rails_logger.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
-
#min_level ⇒ Object
Returns the value of attribute min_level.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #events_endpoint ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/errsight/configuration.rb', line 7 def initialize @api_key = ENV["ERRSIGHT_API_KEY"] @environment = ENV.fetch("ERRSIGHT_ENV", "production") @min_level = :warning @host = ENV.fetch("ERRSIGHT_HOST", "https://errsight.com") @timeout = 5 @enabled = true @batch_size = 10 @flush_interval = 2 # seconds @max_queue_size = 1_000 @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout) @attach_to_rails_logger = true end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def api_key @api_key end |
#attach_to_rails_logger ⇒ Object
Returns the value of attribute attach_to_rails_logger.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def attach_to_rails_logger @attach_to_rails_logger end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def batch_size @batch_size end |
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def enabled @enabled end |
#environment ⇒ Object
Returns the value of attribute environment.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def environment @environment end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def flush_interval @flush_interval end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def logger @logger end |
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def max_queue_size @max_queue_size end |
#min_level ⇒ Object
Returns the value of attribute min_level.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def min_level @min_level end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/errsight/configuration.rb', line 3 def timeout @timeout end |
Instance Method Details
#enabled? ⇒ Boolean
21 22 23 |
# File 'lib/errsight/configuration.rb', line 21 def enabled? @enabled && !api_key.nil? && !api_key.strip.empty? end |
#events_endpoint ⇒ Object
29 30 31 |
# File 'lib/errsight/configuration.rb', line 29 def events_endpoint "#{host.chomp('/')}/api/v1/events" end |
#validate! ⇒ Object
25 26 27 |
# File 'lib/errsight/configuration.rb', line 25 def validate! raise ConfigurationError, "api_key is required" if api_key.nil? || api_key.strip.empty? end |