Class: Bugsnag::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag/configuration.rb

Constant Summary collapse

THREAD_LOCAL_NAME =
"bugsnag_req_data"
DEFAULT_ENDPOINT =
"notify.bugsnag.com"
DEFAULT_PARAMS_FILTERS =
["password"].freeze
DEFAULT_IGNORE_CLASSES =
[
  "ActiveRecord::RecordNotFound",
  "ActionController::RoutingError",
  "ActionController::InvalidAuthenticityToken",
  "CGI::Session::CookieStore::TamperedWithCookie",
  "ActionController::UnknownAction",
  "AbstractController::ActionNotFound",
  "Mongoid::Errors::DocumentNotFound"
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bugsnag/configuration.rb', line 38

def initialize
  # Set up the defaults
  self.release_stage = nil
  self.notify_release_stages = nil
  self.auto_notify = true
  self.use_ssl = false
  self.params_filters = Set.new(DEFAULT_PARAMS_FILTERS)
  self.ignore_classes = Set.new(DEFAULT_IGNORE_CLASSES)
  self.endpoint = DEFAULT_ENDPOINT

  # Set up logging
  self.logger = Logger.new(STDOUT)
  self.logger.level = Logger::WARN

  # Configure the bugsnag middleware stack
  self.middleware = Bugsnag::MiddlewareStack.new
  self.middleware.use Bugsnag::Middleware::Callbacks
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/bugsnag/configuration.rb', line 7

def api_key
  @api_key
end

#app_versionObject

Returns the value of attribute app_version.



13
14
15
# File 'lib/bugsnag/configuration.rb', line 13

def app_version
  @app_version
end

#auto_notifyObject

Returns the value of attribute auto_notify.



10
11
12
# File 'lib/bugsnag/configuration.rb', line 10

def auto_notify
  @auto_notify
end

#debugObject

Returns the value of attribute debug.



20
21
22
# File 'lib/bugsnag/configuration.rb', line 20

def debug
  @debug
end

#delay_with_resqueObject

Returns the value of attribute delay_with_resque.



19
20
21
# File 'lib/bugsnag/configuration.rb', line 19

def delay_with_resque
  @delay_with_resque
end

#endpointObject

Returns the value of attribute endpoint.



16
17
18
# File 'lib/bugsnag/configuration.rb', line 16

def endpoint
  @endpoint
end

#ignore_classesObject

Returns the value of attribute ignore_classes.



15
16
17
# File 'lib/bugsnag/configuration.rb', line 15

def ignore_classes
  @ignore_classes
end

#loggerObject

Returns the value of attribute logger.



17
18
19
# File 'lib/bugsnag/configuration.rb', line 17

def logger
  @logger
end

#middlewareObject

Returns the value of attribute middleware.



18
19
20
# File 'lib/bugsnag/configuration.rb', line 18

def middleware
  @middleware
end

#notify_release_stagesObject

Returns the value of attribute notify_release_stages.



9
10
11
# File 'lib/bugsnag/configuration.rb', line 9

def notify_release_stages
  @notify_release_stages
end

#params_filtersObject

Returns the value of attribute params_filters.



14
15
16
# File 'lib/bugsnag/configuration.rb', line 14

def params_filters
  @params_filters
end

#project_rootObject

Returns the value of attribute project_root.



12
13
14
# File 'lib/bugsnag/configuration.rb', line 12

def project_root
  @project_root
end

#release_stageObject

Returns the value of attribute release_stage.



8
9
10
# File 'lib/bugsnag/configuration.rb', line 8

def release_stage
  @release_stage
end

#use_sslObject

Returns the value of attribute use_ssl.



11
12
13
# File 'lib/bugsnag/configuration.rb', line 11

def use_ssl
  @use_ssl
end

Instance Method Details

#clear_request_dataObject



73
74
75
# File 'lib/bugsnag/configuration.rb', line 73

def clear_request_data
  Thread.current[THREAD_LOCAL_NAME] = nil
end

#request_dataObject



61
62
63
# File 'lib/bugsnag/configuration.rb', line 61

def request_data
  Thread.current[THREAD_LOCAL_NAME] ||= {}
end

#set_request_data(key, value) ⇒ Object



65
66
67
# File 'lib/bugsnag/configuration.rb', line 65

def set_request_data(key, value)
  self.request_data[key] = value
end

#should_notify?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/bugsnag/configuration.rb', line 57

def should_notify?
  @release_stage.nil? || @notify_release_stages.nil? || @notify_release_stages.include?(@release_stage)
end

#unset_request_data(key, value) ⇒ Object



69
70
71
# File 'lib/bugsnag/configuration.rb', line 69

def unset_request_data(key, value)
  self.request_data.delete(key)
end