Module: LighthouseExceptionLogger
- Defined in:
- lib/LighthouseExceptionLogger.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
- VERSION =
'0.1'
- 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
Returns the value of attribute host.
-
.port ⇒ Object
Returns the value of attribute port.
-
.secure ⇒ Object
Returns the value of attribute secure.
Class Method Summary collapse
- .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 Lighthouse.
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
21 22 23 |
# File 'lib/LighthouseExceptionLogger.rb', line 21 def api_key @api_key end |
.backtrace_filters ⇒ Object (readonly)
Returns the value of attribute backtrace_filters.
22 23 24 |
# File 'lib/LighthouseExceptionLogger.rb', line 22 def backtrace_filters @backtrace_filters end |
.host ⇒ Object
Returns the value of attribute host.
21 22 23 |
# File 'lib/LighthouseExceptionLogger.rb', line 21 def host @host end |
.port ⇒ Object
Returns the value of attribute port.
21 22 23 |
# File 'lib/LighthouseExceptionLogger.rb', line 21 def port @port end |
.secure ⇒ Object
Returns the value of attribute secure.
21 22 23 |
# File 'lib/LighthouseExceptionLogger.rb', line 21 def secure @secure end |
Class Method Details
.environment_filters ⇒ Object
51 52 53 |
# File 'lib/LighthouseExceptionLogger.rb', line 51 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]”
28 29 30 |
# File 'lib/LighthouseExceptionLogger.rb', line 28 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.
33 34 35 36 37 |
# File 'lib/LighthouseExceptionLogger.rb', line 33 def ignore @ignore ||= (LighthouseExceptionLogger::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.
41 42 43 |
# File 'lib/LighthouseExceptionLogger.rb', line 41 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.
65 66 67 |
# File 'lib/LighthouseExceptionLogger.rb', line 65 def notify notice = {} Sender.new.notify_lighthouse( notice ) end |
.params_filters ⇒ Object
Returns a list of parameters that should be filtered out of what is sent to Lighthouse. By default, all “password” attributes will have their contents replaced.
47 48 49 |
# File 'lib/LighthouseExceptionLogger.rb', line 47 def params_filters @params_filters ||= %w(password) end |