Class: Batbugger::Notice
- Inherits:
-
Object
- Object
- Batbugger::Notice
- Defined in:
- lib/batbugger/notice.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#backtrace_filters ⇒ Object
readonly
Returns the value of attribute backtrace_filters.
-
#cgi_data ⇒ Object
readonly
Returns the value of attribute cgi_data.
-
#component ⇒ Object
(also: #controller)
readonly
Returns the value of attribute component.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#environment_name ⇒ Object
readonly
Returns the value of attribute environment_name.
-
#error_class ⇒ Object
readonly
Returns the value of attribute error_class.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#ignore_by_filters ⇒ Object
readonly
Returns the value of attribute ignore_by_filters.
-
#notifier_name ⇒ Object
readonly
Returns the value of attribute notifier_name.
-
#notifier_url ⇒ Object
readonly
Returns the value of attribute notifier_url.
-
#notifier_version ⇒ Object
readonly
Returns the value of attribute notifier_version.
-
#parameters ⇒ Object
(also: #params)
readonly
Returns the value of attribute parameters.
-
#params_filters ⇒ Object
readonly
Returns the value of attribute params_filters.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
-
#send_request_session ⇒ Object
readonly
Returns the value of attribute send_request_session.
-
#session_data ⇒ Object
readonly
Returns the value of attribute session_data.
-
#source_extract ⇒ Object
readonly
Returns the value of attribute source_extract.
-
#source_extract_radius ⇒ Object
readonly
Returns the value of attribute source_extract_radius.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #[](method) ⇒ Object
- #as_json(options = {}) ⇒ Object
- #deliver ⇒ Object
- #ignore? ⇒ Boolean
- #ignore_by_class?(ignored_class = nil) ⇒ Boolean
-
#initialize(args) ⇒ Notice
constructor
A new instance of Notice.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(args) ⇒ Notice
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/batbugger/notice.rb', line 55 def initialize(args) self.args = args self.exception = args[:exception] self.project_root = args[:project_root] self.url = args[:url] || rack_env(:url) self.notifier_name = args[:notifier_name] self.notifier_version = args[:notifier_version] self.notifier_url = args[:notifier_url] self.ignore = args[:ignore] || [] self.ignore_by_filters = args[:ignore_by_filters] || [] self.backtrace_filters = args[:backtrace_filters] || [] self.params_filters = args[:params_filters] || [] self.parameters = args[:parameters] || action_dispatch_params || rack_env(:params) || {} self.component = args[:component] || args[:controller] || parameters['controller'] self.action = args[:action] || parameters['action'] self.environment_name = args[:environment_name] self.cgi_data = args[:cgi_data] || args[:rack_env] self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller), :filters => self.backtrace_filters) self.error_class = exception_attribute(:error_class) {|exception| exception.class.name } self. = exception_attribute(:error_message, 'Notification') do |exception| "#{exception.class.name}: #{exception.message}" end self.hostname = local_hostname self.source_extract_radius = args[:source_extract_radius] || 2 self.source_extract = extract_source_from_backtrace self.send_request_session = args[:send_request_session].nil? ? true : args[:send_request_session] also_use_rack_params_filters find_session_data clean_params clean_rack_request_data set_context end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
33 34 35 |
# File 'lib/batbugger/notice.rb', line 33 def action @action end |
#backtrace ⇒ Object
Returns the value of attribute backtrace.
7 8 9 |
# File 'lib/batbugger/notice.rb', line 7 def backtrace @backtrace end |
#backtrace_filters ⇒ Object
Returns the value of attribute backtrace_filters.
23 24 25 |
# File 'lib/batbugger/notice.rb', line 23 def backtrace_filters @backtrace_filters end |
#cgi_data ⇒ Object
Returns the value of attribute cgi_data.
17 18 19 |
# File 'lib/batbugger/notice.rb', line 17 def cgi_data @cgi_data end |
#component ⇒ Object Also known as: controller
Returns the value of attribute component.
30 31 32 |
# File 'lib/batbugger/notice.rb', line 30 def component @component end |
#context ⇒ Object
Returns the value of attribute context.
37 38 39 |
# File 'lib/batbugger/notice.rb', line 37 def context @context end |
#environment_name ⇒ Object
Returns the value of attribute environment_name.
15 16 17 |
# File 'lib/batbugger/notice.rb', line 15 def environment_name @environment_name end |
#error_class ⇒ Object
Returns the value of attribute error_class.
9 10 11 |
# File 'lib/batbugger/notice.rb', line 9 def error_class @error_class end |
#error_message ⇒ Object
Returns the value of attribute error_message.
19 20 21 |
# File 'lib/batbugger/notice.rb', line 19 def end |
#exception ⇒ Object
Returns the value of attribute exception.
5 6 7 |
# File 'lib/batbugger/notice.rb', line 5 def exception @exception end |
#hostname ⇒ Object
Returns the value of attribute hostname.
53 54 55 |
# File 'lib/batbugger/notice.rb', line 53 def hostname @hostname end |
#ignore ⇒ Object
Returns the value of attribute ignore.
43 44 45 |
# File 'lib/batbugger/notice.rb', line 43 def ignore @ignore end |
#ignore_by_filters ⇒ Object
Returns the value of attribute ignore_by_filters.
45 46 47 |
# File 'lib/batbugger/notice.rb', line 45 def ignore_by_filters @ignore_by_filters end |
#notifier_name ⇒ Object
Returns the value of attribute notifier_name.
47 48 49 |
# File 'lib/batbugger/notice.rb', line 47 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
Returns the value of attribute notifier_url.
51 52 53 |
# File 'lib/batbugger/notice.rb', line 51 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
Returns the value of attribute notifier_version.
49 50 51 |
# File 'lib/batbugger/notice.rb', line 49 def notifier_version @notifier_version end |
#parameters ⇒ Object Also known as: params
Returns the value of attribute parameters.
27 28 29 |
# File 'lib/batbugger/notice.rb', line 27 def parameters @parameters end |
#params_filters ⇒ Object
Returns the value of attribute params_filters.
25 26 27 |
# File 'lib/batbugger/notice.rb', line 25 def params_filters @params_filters end |
#project_root ⇒ Object
Returns the value of attribute project_root.
39 40 41 |
# File 'lib/batbugger/notice.rb', line 39 def project_root @project_root end |
#send_request_session ⇒ Object
Returns the value of attribute send_request_session.
21 22 23 |
# File 'lib/batbugger/notice.rb', line 21 def send_request_session @send_request_session end |
#session_data ⇒ Object
Returns the value of attribute session_data.
35 36 37 |
# File 'lib/batbugger/notice.rb', line 35 def session_data @session_data end |
#source_extract ⇒ Object
Returns the value of attribute source_extract.
11 12 13 |
# File 'lib/batbugger/notice.rb', line 11 def source_extract @source_extract end |
#source_extract_radius ⇒ Object
Returns the value of attribute source_extract_radius.
13 14 15 |
# File 'lib/batbugger/notice.rb', line 13 def source_extract_radius @source_extract_radius end |
#url ⇒ Object
Returns the value of attribute url.
41 42 43 |
# File 'lib/batbugger/notice.rb', line 41 def url @url end |
Instance Method Details
#[](method) ⇒ Object
155 156 157 158 159 160 161 162 |
# File 'lib/batbugger/notice.rb', line 155 def [](method) case method when :request self else send(method) end end |
#as_json(options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/batbugger/notice.rb', line 102 def as_json( = {}) { :notifier => { :name => notifier_name, :url => notifier_url, :version => notifier_version, :language => 'ruby' }, :error => { :class => error_class, :message => , :backtrace => backtrace, :source => source_extract }, :request => { :url => url, :component => component, :action => action, :params => parameters, :session => session_data, :cgi_data => cgi_data, :context => context }, :server => { :project_root => project_root, :environment_name => environment_name, :hostname => hostname } } end |
#deliver ⇒ Object
98 99 100 |
# File 'lib/batbugger/notice.rb', line 98 def deliver Batbugger.sender.send_to_batbugger(self) end |
#ignore? ⇒ Boolean
150 151 152 153 |
# File 'lib/batbugger/notice.rb', line 150 def ignore? ignore.any?(&ignore_by_class?) || ignore_by_filters.any? {|filter| filter.call(self) } end |
#ignore_by_class?(ignored_class = nil) ⇒ Boolean
137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/batbugger/notice.rb', line 137 def ignore_by_class?(ignored_class = nil) @ignore_by_class ||= Proc.new do |ignored_class| case error_class when (ignored_class.respond_to?(:name) ? ignored_class.name : ignored_class) true else exception && ignored_class.is_a?(Class) && exception.class < ignored_class end end ignored_class ? @ignore_by_class.call(ignored_class) : @ignore_by_class end |
#to_json(*a) ⇒ Object
133 134 135 |
# File 'lib/batbugger/notice.rb', line 133 def to_json(*a) as_json.to_json(*a) end |