-
Notifications
You must be signed in to change notification settings - Fork 175
/
configuration.rb
77 lines (64 loc) · 2.07 KB
/
configuration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require "set"
require "logger"
require "bugsnag/middleware_stack"
module Bugsnag
class Configuration
attr_accessor :api_key
attr_accessor :release_stage
attr_accessor :notify_release_stages
attr_accessor :auto_notify
attr_accessor :use_ssl
attr_accessor :project_root
attr_accessor :app_version
attr_accessor :params_filters
attr_accessor :ignore_classes
attr_accessor :endpoint
attr_accessor :logger
attr_accessor :middleware
attr_accessor :delay_with_resque
attr_accessor :debug
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
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
def should_notify?
@release_stage.nil? || @notify_release_stages.nil? || @notify_release_stages.include?(@release_stage)
end
def request_data
Thread.current[THREAD_LOCAL_NAME] ||= {}
end
def set_request_data(key, value)
self.request_data[key] = value
end
def unset_request_data(key, value)
self.request_data.delete(key)
end
def clear_request_data
Thread.current[THREAD_LOCAL_NAME] = nil
end
end
end