Module: ErrornotNotifier
- Defined in:
- lib/errornot_notifier.rb,
lib/errornot_notifier/rack.rb,
lib/errornot_notifier/rails.rb,
lib/errornot_notifier/notice.rb,
lib/errornot_notifier/sender.rb,
lib/errornot_notifier/railtie.rb,
lib/errornot_notifier/version.rb,
lib/errornot_notifier/backtrace.rb,
lib/errornot_notifier/configuration.rb,
lib/errornot_notifier/rails/error_lookup.rb,
lib/errornot_notifier/rails/controller_methods.rb,
lib/errornot_notifier/rails/javascript_notifier.rb,
lib/errornot_notifier/rails/action_controller_catcher.rb
Overview
Gem for applications to automatically post errors to the Errornot of their choice.
Defined Under Namespace
Modules: Rails Classes: Backtrace, Configuration, Notice, Rack, Railtie, Sender
Constant Summary collapse
- API_VERSION =
"1.0"
- LOG_PREFIX =
"** [ErrorNot Logger] "
- HEADERS =
{ 'Content-type' => 'application/x-www-form-urlencoded', 'Accept' => 'text/json' }
- VERSION =
"1.1.1".freeze
Class Attribute Summary collapse
-
.configuration ⇒ Object
A Errornot configuration object.
-
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Errornot server.
Class Method Summary collapse
- .build_lookup_hash_for(exception, options = {}) ⇒ Object
-
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
-
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment.
-
.logger ⇒ Object
Look for the Rails logger currently defined.
-
.notify(exception, opts = {}) ⇒ Object
Sends an exception manually using this method, even when you are not in a controller.
-
.notify_or_ignore(exception, opts = {}) ⇒ Object
Sends the notice unless it is one of the default ignored exceptions.
-
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help.
-
.report_ready ⇒ Object
Tell the log that the Notifier is good to go.
-
.report_response_body(response) ⇒ Object
Prints out the response body from Errornot for debugging help.
-
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger.
Class Attribute Details
.configuration ⇒ Object
A Errornot configuration object. Must act like a hash and return sensible values for all Errornot configuration options. See ErrornotNotifier::Configuration.
33 34 35 |
# File 'lib/errornot_notifier.rb', line 33 def configuration @configuration end |
.sender ⇒ Object
The sender object is responsible for delivering formatted data to the Errornot server. Must respond to #send_to_errornot. See ErrornotNotifier::Sender.
29 30 31 |
# File 'lib/errornot_notifier.rb', line 29 def sender @sender end |
Class Method Details
.build_lookup_hash_for(exception, options = {}) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/errornot_notifier.rb', line 103 def build_lookup_hash_for(exception, = {}) notice = build_notice_for(exception, ) result = {} result[:action] = notice.action rescue nil result[:component] = notice.component rescue nil result[:error_class] = notice.error_class if notice.error_class result[:environment_name] = 'production' unless notice.backtrace.lines.empty? result[:file] = notice.backtrace.lines.first.file result[:line_number] = notice.backtrace.lines.first.number end result end |
.configure(silent = false) {|configuration| ... } ⇒ Object
Call this method to modify defaults in your initializers.
74 75 76 77 78 79 |
# File 'lib/errornot_notifier.rb', line 74 def configure(silent = false) self.configuration ||= Configuration.new yield(configuration) self.sender = Sender.new(configuration) report_ready unless silent end |
.environment_info ⇒ Object
Returns the Ruby version, Rails version, and current Rails environment
51 52 53 54 55 |
# File 'lib/errornot_notifier.rb', line 51 def environment_info info = "[Ruby: #{RUBY_VERSION}]" info << " [#{configuration.framework}]" info << " [Env: #{configuration.environment_name}]" end |
.logger ⇒ Object
Look for the Rails logger currently defined
63 64 65 |
# File 'lib/errornot_notifier.rb', line 63 def logger self.configuration.logger end |
.notify(exception, opts = {}) ⇒ Object
Sends an exception manually using this method, even when you are not in a controller.
92 93 94 |
# File 'lib/errornot_notifier.rb', line 92 def notify(exception, opts = {}) send_notice(build_notice_for(exception, opts)) end |
.notify_or_ignore(exception, opts = {}) ⇒ Object
Sends the notice unless it is one of the default ignored exceptions
98 99 100 101 |
# File 'lib/errornot_notifier.rb', line 98 def notify_or_ignore(exception, opts = {}) notice = build_notice_for(exception, opts) send_notice(notice) unless notice.ignore? end |
.report_environment_info ⇒ Object
Prints out the environment info to the log for debugging help
41 42 43 |
# File 'lib/errornot_notifier.rb', line 41 def report_environment_info write_verbose_log("Environment Info: #{environment_info}") end |
.report_ready ⇒ Object
Tell the log that the Notifier is good to go
36 37 38 |
# File 'lib/errornot_notifier.rb', line 36 def report_ready write_verbose_log("Notifier #{VERSION} ready to catch errors") end |
.report_response_body(response) ⇒ Object
Prints out the response body from Errornot for debugging help
46 47 48 |
# File 'lib/errornot_notifier.rb', line 46 def report_response_body(response) write_verbose_log("Response from Errornot: \n#{response}") end |
.write_verbose_log(message) ⇒ Object
Writes out the given message to the #logger
58 59 60 |
# File 'lib/errornot_notifier.rb', line 58 def write_verbose_log() logger.info LOG_PREFIX + if logger end |