Class: ErrornotNotifier::Configuration
- Inherits:
-
Object
- Object
- ErrornotNotifier::Configuration
- Defined in:
- lib/errornot_notifier/configuration.rb
Overview
Used to set up and modify settings for the notifier.
Constant Summary collapse
- OPTIONS =
[:api_key, :backtrace_filters, :development_environments, :development_lookup, :environment_name, :host, :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version, :params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port, :proxy_user, :secure, :framework, :js_notifier].freeze
- DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
- DEFAULT_BACKTRACE_FILTERS =
[ lambda { |line| if defined?(ErrornotNotifier.configuration.project_root) && ErrornotNotifier.configuration.project_root.to_s != '' line.gsub(/#{ErrornotNotifier.configuration.project_root}/, "[PROJECT_ROOT]") else line end }, lambda { |line| line.gsub(/^\.\//, "") }, lambda { |line| if defined?(Gem) Gem.path.inject(line) do |line, path| line.gsub(/#{path}/, "[GEM_ROOT]") end end }, lambda { |line| line if line !~ %r{lib/errornot_notifier} } ].freeze
- IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound', 'ActionController::RoutingError', 'ActionController::InvalidAuthenticityToken', 'CGI::Session::CookieStore::TamperedWithCookie', 'ActionController::UnknownAction']
Instance Attribute Summary collapse
-
#api_key ⇒ Object
The API key for your project, found on the project edit form.
-
#backtrace_filters ⇒ Object
readonly
A list of filters for cleaning and pruning the backtrace.
-
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
-
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors,false
otherwise. -
#environment_name ⇒ Object
The name of the environment the application is running in.
-
#framework ⇒ Object
The framework ErrornotNotifier is configured to use.
-
#host ⇒ Object
The host to connect, there are no default value.
-
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
-
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
-
#ignore ⇒ Object
readonly
A list of exception classes to ignore.
-
#ignore_by_filters ⇒ Object
readonly
A list of filters for ignoring exceptions.
-
#ignore_user_agent ⇒ Object
readonly
A list of user agents that are being ignored.
-
#js_notifier ⇒ Object
true
if you want to enable the JavaScript notifier in production environments. -
#logger ⇒ Object
The logger used by ErrornotNotifier.
-
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Errornot Notifier”).
-
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications.
-
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”).
-
#params_filters ⇒ Object
readonly
A list of parameters that should be filtered out of what is sent to Errornot.
-
#port ⇒ Object
The port on which your Errornot server runs we can advise to prefere 443 for a secure connection.
-
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT.
-
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy).
-
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy).
-
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy).
-
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy).
-
#secure ⇒ Object
(also: #secure?)
true
for https connections,false
for http connections.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #environment_filters ⇒ Object
-
#filter_backtrace(&block) {|line| ... } ⇒ Object
Takes a block and adds it to the list of backtrace filters.
-
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters.
-
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
-
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash
. - #protocol ⇒ Object
-
#public? ⇒ Boolean
Determines if the notifier will send notices.
-
#to_hash ⇒ Object
Returns a hash of all configurable options.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/errornot_notifier/configuration.rb', line 118 def initialize @secure = false @http_open_timeout = 2 @http_read_timeout = 5 @params_filters = DEFAULT_PARAMS_FILTERS.dup @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup @ignore_by_filters = [] @ignore = IGNORE_DEFAULT.dup @ignore_user_agent = [] @development_environments = %w(development test cucumber) @development_lookup = true @notifier_name = 'Errornot Notifier' @js_notifier = false @notifier_version = VERSION @framework = 'Standalone' end |
Instance Attribute Details
#api_key ⇒ Object
The API key for your project, found on the project edit form.
13 14 15 |
# File 'lib/errornot_notifier/configuration.rb', line 13 def api_key @api_key end |
#backtrace_filters ⇒ Object (readonly)
A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
48 49 50 |
# File 'lib/errornot_notifier/configuration.rb', line 48 def backtrace_filters @backtrace_filters end |
#development_environments ⇒ Object
A list of environments in which notifications should not be sent.
60 61 62 |
# File 'lib/errornot_notifier/configuration.rb', line 60 def development_environments @development_environments end |
#development_lookup ⇒ Object
true
if you want to check for production errors matching development errors, false
otherwise.
63 64 65 |
# File 'lib/errornot_notifier/configuration.rb', line 63 def development_lookup @development_lookup end |
#environment_name ⇒ Object
The name of the environment the application is running in
69 70 71 |
# File 'lib/errornot_notifier/configuration.rb', line 69 def environment_name @environment_name end |
#framework ⇒ Object
The framework ErrornotNotifier is configured to use
87 88 89 |
# File 'lib/errornot_notifier/configuration.rb', line 87 def framework @framework end |
#host ⇒ Object
The host to connect, there are no default value
16 17 18 |
# File 'lib/errornot_notifier/configuration.rb', line 16 def host @host end |
#http_open_timeout ⇒ Object
The HTTP open timeout in seconds (defaults to 2).
26 27 28 |
# File 'lib/errornot_notifier/configuration.rb', line 26 def http_open_timeout @http_open_timeout end |
#http_read_timeout ⇒ Object
The HTTP read timeout in seconds (defaults to 5).
29 30 31 |
# File 'lib/errornot_notifier/configuration.rb', line 29 def http_read_timeout @http_read_timeout end |
#ignore ⇒ Object (readonly)
A list of exception classes to ignore. The array can be appended to.
54 55 56 |
# File 'lib/errornot_notifier/configuration.rb', line 54 def ignore @ignore end |
#ignore_by_filters ⇒ Object (readonly)
A list of filters for ignoring exceptions. See #ignore_by_filter.
51 52 53 |
# File 'lib/errornot_notifier/configuration.rb', line 51 def ignore_by_filters @ignore_by_filters end |
#ignore_user_agent ⇒ Object (readonly)
A list of user agents that are being ignored. The array can be appended to.
57 58 59 |
# File 'lib/errornot_notifier/configuration.rb', line 57 def ignore_user_agent @ignore_user_agent end |
#js_notifier ⇒ Object
true
if you want to enable the JavaScript notifier in production environments
66 67 68 |
# File 'lib/errornot_notifier/configuration.rb', line 66 def js_notifier @js_notifier end |
#logger ⇒ Object
The logger used by ErrornotNotifier
84 85 86 |
# File 'lib/errornot_notifier/configuration.rb', line 84 def logger @logger end |
#notifier_name ⇒ Object
The name of the notifier library being used to send notifications (such as “Errornot Notifier”)
75 76 77 |
# File 'lib/errornot_notifier/configuration.rb', line 75 def notifier_name @notifier_name end |
#notifier_url ⇒ Object
The url of the notifier library being used to send notifications
81 82 83 |
# File 'lib/errornot_notifier/configuration.rb', line 81 def notifier_url @notifier_url end |
#notifier_version ⇒ Object
The version of the notifier library being used to send notifications (such as “1.0.2”)
78 79 80 |
# File 'lib/errornot_notifier/configuration.rb', line 78 def notifier_version @notifier_version end |
#params_filters ⇒ Object (readonly)
A list of parameters that should be filtered out of what is sent to Errornot. By default, all “password” attributes will have their contents replaced.
45 46 47 |
# File 'lib/errornot_notifier/configuration.rb', line 45 def params_filters @params_filters end |
#port ⇒ Object
The port on which your Errornot server runs we can advise to prefere 443 for a secure connection
20 21 22 |
# File 'lib/errornot_notifier/configuration.rb', line 20 def port @port end |
#project_root ⇒ Object
The path to the project in which the error occurred, such as the RAILS_ROOT
72 73 74 |
# File 'lib/errornot_notifier/configuration.rb', line 72 def project_root @project_root end |
#proxy_host ⇒ Object
The hostname of your proxy server (if using a proxy)
32 33 34 |
# File 'lib/errornot_notifier/configuration.rb', line 32 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object
The password to use when logging into your proxy server (if using a proxy)
41 42 43 |
# File 'lib/errornot_notifier/configuration.rb', line 41 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
The port of your proxy server (if using a proxy)
35 36 37 |
# File 'lib/errornot_notifier/configuration.rb', line 35 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
The username to use when logging into your proxy server (if using a proxy)
38 39 40 |
# File 'lib/errornot_notifier/configuration.rb', line 38 def proxy_user @proxy_user end |
#secure ⇒ Object Also known as: secure?
true
for https connections, false
for http connections.
23 24 25 |
# File 'lib/errornot_notifier/configuration.rb', line 23 def secure @secure end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
181 182 183 |
# File 'lib/errornot_notifier/configuration.rb', line 181 def [](option) send(option) end |
#environment_filters ⇒ Object
217 218 219 220 |
# File 'lib/errornot_notifier/configuration.rb', line 217 def environment_filters warn 'config.environment_filters has been deprecated and has no effect.' [] end |
#filter_backtrace(&block) {|line| ... } ⇒ 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.
146 147 148 |
# File 'lib/errornot_notifier/configuration.rb', line 146 def filter_backtrace(&block) self.backtrace_filters << block end |
#ignore_by_filter(&block) {|data| ... } ⇒ Object
Takes a block and adds it to the list of ignore filters. When the filters run, the block will be handed the exception.
160 161 162 |
# File 'lib/errornot_notifier/configuration.rb', line 160 def ignore_by_filter(&block) self.ignore_by_filters << block end |
#ignore_only=(names) ⇒ Object
Overrides the list of default ignored errors.
167 168 169 |
# File 'lib/errornot_notifier/configuration.rb', line 167 def ignore_only=(names) @ignore = [names].flatten end |
#ignore_user_agent_only=(names) ⇒ Object
Overrides the list of default ignored user agents
174 175 176 |
# File 'lib/errornot_notifier/configuration.rb', line 174 def ignore_user_agent_only=(names) @ignore_user_agent = [names].flatten end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
195 196 197 |
# File 'lib/errornot_notifier/configuration.rb', line 195 def merge(hash) to_hash.merge(hash) end |
#protocol ⇒ Object
209 210 211 212 213 214 215 |
# File 'lib/errornot_notifier/configuration.rb', line 209 def protocol if secure? 'https' else 'http' end end |
#public? ⇒ Boolean
Determines if the notifier will send notices.
201 202 203 |
# File 'lib/errornot_notifier/configuration.rb', line 201 def public? !development_environments.include?(environment_name) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
186 187 188 189 190 |
# File 'lib/errornot_notifier/configuration.rb', line 186 def to_hash OPTIONS.inject({}) do |hash, option| hash.merge(option.to_sym => send(option)) end end |