Module: HoptoadNotifier
- Defined in:
- lib/hoptoad_notifier.rb
Overview
Plugin for applications to automatically post errors to the Hoptoad of their choice.
Defined Under Namespace
Modules: Catcher Classes: Sender
Constant Summary collapse
- IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound', 'ActionController::RoutingError', 'ActionController::InvalidAuthenticityToken', 'CGI::Session::CookieStore::TamperedWithCookie']
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.backtrace_filters ⇒ Object
readonly
Returns the value of attribute backtrace_filters.
-
.host ⇒ Object
The host to connect to.
-
.http_open_timeout ⇒ Object
The HTTP open timeout (defaults to 2 seconds).
-
.http_read_timeout ⇒ Object
The HTTP read timeout (defaults to 5 seconds).
-
.port ⇒ Object
The port on which your Hoptoad server runs.
-
.proxy_host ⇒ Object
Returns the value of attribute proxy_host.
-
.proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
-
.proxy_port ⇒ Object
Returns the value of attribute proxy_port.
-
.proxy_user ⇒ Object
Returns the value of attribute proxy_user.
-
.secure ⇒ Object
Returns the value of attribute secure.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Call this method to modify defaults in your initializers.
-
.default_notice_options ⇒ Object
:nodoc:.
- .environment_filters ⇒ Object
-
.filter_backtrace(&block) ⇒ Object
Takes a block and adds it to the list of backtrace filters.
-
.ignore ⇒ Object
Returns the list of errors that are being ignored.
-
.ignore_only=(names) ⇒ Object
Sets the list of ignored errors to only what is passed in here.
-
.notify(notice = {}) ⇒ Object
You can send an exception manually using this method, even when you are not in a controller.
-
.params_filters ⇒ Object
Returns a list of parameters that should be filtered out of what is sent to Hoptoad.
-
.protocol ⇒ Object
:nodoc:.
-
.url ⇒ Object
:nodoc:.
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def api_key @api_key end |
.backtrace_filters ⇒ Object (readonly)
Returns the value of attribute backtrace_filters.
21 22 23 |
# File 'lib/hoptoad_notifier.rb', line 21 def backtrace_filters @backtrace_filters end |
.host ⇒ Object
The host to connect to.
37 38 39 |
# File 'lib/hoptoad_notifier.rb', line 37 def host @host end |
.http_open_timeout ⇒ Object
The HTTP open timeout (defaults to 2 seconds).
42 43 44 |
# File 'lib/hoptoad_notifier.rb', line 42 def http_open_timeout @http_open_timeout end |
.http_read_timeout ⇒ Object
The HTTP read timeout (defaults to 5 seconds).
47 48 49 |
# File 'lib/hoptoad_notifier.rb', line 47 def http_read_timeout @http_read_timeout end |
.port ⇒ Object
The port on which your Hoptoad server runs.
32 33 34 |
# File 'lib/hoptoad_notifier.rb', line 32 def port @port end |
.proxy_host ⇒ Object
Returns the value of attribute proxy_host.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def proxy_host @proxy_host end |
.proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def proxy_pass @proxy_pass end |
.proxy_port ⇒ Object
Returns the value of attribute proxy_port.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def proxy_port @proxy_port end |
.proxy_user ⇒ Object
Returns the value of attribute proxy_user.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def proxy_user @proxy_user end |
.secure ⇒ Object
Returns the value of attribute secure.
19 20 21 |
# File 'lib/hoptoad_notifier.rb', line 19 def secure @secure end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Call this method to modify defaults in your initializers.
HoptoadNotifier.configure do |config|
config.api_key = '1234567890abcdef'
config.secure = false
end
NOTE: secure connections are not yet supported.
82 83 84 |
# File 'lib/hoptoad_notifier.rb', line 82 def configure yield self end |
.default_notice_options ⇒ Object
:nodoc:
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/hoptoad_notifier.rb', line 94 def #:nodoc: { :api_key => HoptoadNotifier.api_key, :error_message => 'Notification', :backtrace => caller, :request => {}, :session => {}, :environment => ENV.to_hash } end |
.environment_filters ⇒ Object
70 71 72 |
# File 'lib/hoptoad_notifier.rb', line 70 def environment_filters @environment_filters ||= %w() end |
.filter_backtrace(&block) ⇒ Object
Takes a block and adds it to the list of backtrace filters. When the filters run, the block will be handed each line of the backtrace and can modify it as necessary. For example, by default a path matching the RAILS_ROOT constant will be transformed into “[RAILS_ROOT]”
27 28 29 |
# File 'lib/hoptoad_notifier.rb', line 27 def filter_backtrace &block (@backtrace_filters ||= []) << block end |
.ignore ⇒ Object
Returns the list of errors that are being ignored. The array can be appended to.
52 53 54 55 56 |
# File 'lib/hoptoad_notifier.rb', line 52 def ignore @ignore ||= (HoptoadNotifier::IGNORE_DEFAULT.dup) @ignore.flatten! @ignore end |
.ignore_only=(names) ⇒ Object
Sets the list of ignored errors to only what is passed in here. This method can be passed a single error or a list of errors.
60 61 62 |
# File 'lib/hoptoad_notifier.rb', line 60 def ignore_only=(names) @ignore = [names].flatten end |
.notify(notice = {}) ⇒ Object
You can send an exception manually using this method, even when you are not in a controller. You can pass an exception or a hash that contains the attributes that would be sent to Hoptoad:
-
api_key: The API key for this project. The API key is a unique identifier that Hoptoad uses for identification.
-
error_message: The error returned by the exception (or the message you want to log).
-
backtrace: A backtrace, usually obtained with
caller
. -
request: The controller’s request object.
-
session: The contents of the user’s session.
-
environment: ENV merged with the contents of the request’s environment.
115 116 117 |
# File 'lib/hoptoad_notifier.rb', line 115 def notify notice = {} Sender.new.notify_hoptoad( notice ) end |
.params_filters ⇒ Object
Returns a list of parameters that should be filtered out of what is sent to Hoptoad. By default, all “password” attributes will have their contents replaced.
66 67 68 |
# File 'lib/hoptoad_notifier.rb', line 66 def params_filters @params_filters ||= %w(password) end |
.protocol ⇒ Object
:nodoc:
86 87 88 |
# File 'lib/hoptoad_notifier.rb', line 86 def protocol #:nodoc: secure ? "https" : "http" end |
.url ⇒ Object
:nodoc:
90 91 92 |
# File 'lib/hoptoad_notifier.rb', line 90 def url #:nodoc: URI.parse("#{protocol}://#{host}:#{port}/notices/") end |